Invalid Bitmap.Save parameter

I use Bitmap.Save(location,coded,parameters) to save the first frame of the tiff image: the encoding scheme used is the Tiff format. Then I use saveadd() and so on. Works like a charm on winning 7 bits 64 bits, but does not work on 32-bit versions and older versions of Windows.

After researching, I found that this could be due to the tiff image encoding processed differently with those before GDI +.

Is there a way to overcome this without any major changes?

Sources:

The parameter is invalid by calling Bitmap.Save ()

http://social.msdn.microsoft.com/Forums/fi-FI/netfxbcl/thread/1585c562-f7a9-4cfd-9674-6855ffaa8653

+4
source share
2 answers

Ok, finally found a resolution. The problem is the compression format specified as one of the input parameters for Save () and how GDI + works.

Solution 1:

The compression format must be changed to the one supported in these windows. For example, (long)EncoderValue.CompressionLZW compression in .net works in this case instead of (long)EncoderValue.CompressionCCITT4 .

But the size of the images will be higher than the size of the file created by CCITT4. CCITT4 is also for bitmap images only, and LZW is suitable for most images. Therefore, just think ahead of these problems, as in most places where TIFF imaging is used, not much attention is paid to the compression used and this problem.

Or an alternative solution can be found below [I have not tried it yet]

Solution 2:

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/1585c562-f7a9-4cfd-9674-6855ffaa8653/

Additional reading:

So, the question of which compression to choose and why might arise, which you can refer to:

https://stackoverflow.com/questions/3478292/whats-the-recommended-tiff-compression-for-color-photos/3480411#3480411

+1
source

You must use "long" for the quality parameter

 EncoderParameters parametre = new EncoderParameters(1); parametre.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (quality as long)); 

or

 EncoderParameters parametre = new EncoderParameters(1); parametre.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 90L); 

or

 long quality=90; // EncoderParameters parametre = new EncoderParameters(1); parametre.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality); 
+9
source

All Articles