久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

參數(shù)空異常位圖保存到內(nèi)存流

argumentnullexception bitmap save to memorystream(參數(shù)空異常位圖保存到內(nèi)存流)
本文介紹了參數(shù)空異常位圖保存到內(nèi)存流的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在嘗試將我的位圖保存到 MemoryStream - 這段代碼有什么問題?為什么它讓我argumentnullexception ?

I'm trying to save my Bitmap to MemoryStream - what wrong in this code? Why it gets me argumentnullexception ??

private void insertBarCodesToPDF(Bitmap barcode)
    {

            .......
            MemoryStream ms = new MemoryStream();
            barcode.Save(ms, System.Drawing.Imaging.ImageFormat.MemoryBmp); //<----
            byte [] qwe = ms.ToArray();
            .......

    }

UPD: StackTraceSystem.Drawing.Image.Save(流流,ImageCodecInfo 編碼器,EncoderParameters 編碼器參數(shù))在 WordTest.FormTestWord.insertBarCodesToPDF(位圖條碼)

UPD: StackTrace System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) in WordTest.FormTestWord.insertBarCodesToPDF(Bitmap barcode)

推薦答案

我相信您的問題與您嘗試保存到 MemoryStream 的圖像類型有關(guān).根據(jù)此代碼項目文章:動態(tài)生成圖標(biāo)(安全),一些 ImageFormat類型沒有必要的編碼器來允許保存功能保存為該類型.

I believe that your problem is related to the type of image you are trying to save to the MemoryStream as. According to this Code Project article: Dynamically Generating Icons (safely), some of the ImageFormat types do not have the necessary encoder to allow the Save function to save as that type.

我運行以下命令來確定哪些類型有效,哪些無效:

I ran the following to determine which types did and didn't work:

System.Drawing.Bitmap b = new Bitmap(10, 10);
foreach (ImageFormat format in new ImageFormat[]{
          ImageFormat.Bmp, 
          ImageFormat.Emf, 
          ImageFormat.Exif, 
          ImageFormat.Gif, 
          ImageFormat.Icon, 
          ImageFormat.Jpeg, 
          ImageFormat.MemoryBmp,
          ImageFormat.Png,
          ImageFormat.Tiff, 
          ImageFormat.Wmf}) 
{
  Console.Write("Trying {0}:", format);
  MemoryStream ms = new MemoryStream();
  bool success = true;
  try 
  {
    b.Save(ms, format);
  }
  catch (Exception) 
  {
    success = false;
  }
  Console.WriteLine("	{0}", (success ? "works" : "fails"));
}

結(jié)果如下:

Trying Bmp:       works
Trying Emf:       fails
Trying Exif:      fails
Trying Gif:       works
Trying Icon:      fails
Trying Jpeg:      works
Trying MemoryBMP: fails
Trying Png:       works
Trying Tiff:      works
Trying Wmf:       fails

有一個 Microsoft KB 文章,其中指出某些 ImageFormat類型是只讀的.

There is a Microsoft KB Article which states that some of the ImageFormat types are read-only.

這篇關(guān)于參數(shù)空異常位圖保存到內(nèi)存流的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Right-click on a Listbox in a Silverlight 4 app(右鍵單擊 Silverlight 4 應(yīng)用程序中的列表框)
WPF c# webbrowser scrolls over top menu(WPF c# webbrowser 在頂部菜單上滾動)
C# Console app - How do I make an interactive menu?(C# 控制臺應(yīng)用程序 - 如何制作交互式菜單?)
How to avoid duplicate form creation in .NET Windows Forms?(如何避免在 .NET Windows Forms 中創(chuàng)建重復(fù)的表單?)
UI Automation Control Desktop Application and Click on Menu Strip(UI自動化控制桌面應(yīng)用程序并單擊菜單條)
Removing thin border around the menuitems(刪除菜單項周圍的細邊框)
主站蜘蛛池模板: 欧美一区 | 五月天激情国产综合婷婷婷 | 18国产免费视频动漫 | 春色导航| 精品一区二区三区中文字幕 | 国产综合自拍 | 久久伊人热 | 欧美一区在线视频 | 欧美日韩中文字幕在线观看 | 国产精品久久久久久久 | 日韩在线播放视频 | 国产日韩久久 | 福利视频免费观看 | 欧美区日韩区 | 国产免费一区 | 黄色直接看| 欧美精品久久久久久久 | 制中文字幕音影 | 色婷婷综合网 | 欧美精品日韩少妇 | 日本在线网站 | 午夜国产视频 | 久久国| 欧美久久久久久 | av色在线 | 久久人人视频 | 国产一区二区福利 | 国产一区二区在线观看视频 | 免费高清av | 天堂中文资源在线 | 韩日中文字幕 | 免费黄色小说网站 | 欧美片网站yy | 手机看片1024日韩 | 亚洲va| 精东影业一区二区三区 | 国产无遮挡又黄又爽免费网站 | 国产精品视频久久久 | 久久艳片www.17c.com | 欧美日韩综合在线 | 一级做a爱片性色毛片 |