Background of a saved image problem
-
Hi, I am having problems with the background of the image after it has been rotated and then saved. It saves the rotated image fine but it has a black background but i would like it to be transparent, similar to what occurs under Windows Operating System. I tried using MakeTransparent method before but doesnt seem to work. Here is the code:
//cast the Image to Bitmap
Bitmap temp = (Bitmap)ActualImage;
Color c = temp.GetPixel(1,1);
//temp.SetPixel(1, 1, Color.Transparent);
temp.MakeTransparent(c);
.......
sfdlg.SaveImage(sfdlg.FileName,temp,80);Could anybody assist me with this please? Thanks
-
Hi, I am having problems with the background of the image after it has been rotated and then saved. It saves the rotated image fine but it has a black background but i would like it to be transparent, similar to what occurs under Windows Operating System. I tried using MakeTransparent method before but doesnt seem to work. Here is the code:
//cast the Image to Bitmap
Bitmap temp = (Bitmap)ActualImage;
Color c = temp.GetPixel(1,1);
//temp.SetPixel(1, 1, Color.Transparent);
temp.MakeTransparent(c);
.......
sfdlg.SaveImage(sfdlg.FileName,temp,80);Could anybody assist me with this please? Thanks
I don't know what method you use there to save your file, but my guess is you save it as a bitmap (bmp). If so, then I must inform you that bitmaps (bmp files) do not support transparency... the gif and png file format on the other hand supports transparency.
I have no smart signature yet...
-
I don't know what method you use there to save your file, but my guess is you save it as a bitmap (bmp). If so, then I must inform you that bitmaps (bmp files) do not support transparency... the gif and png file format on the other hand supports transparency.
I have no smart signature yet...
Hi, I am saving the images as JPEGs and i am using the following code: credit goes to microsoft
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
private void SaveJPGWithCompressionSetting( Image image, string szFileName, long lCompression )
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, lCompression );
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
image.Save( szFileName, ici, eps );
} -
Hi, I am saving the images as JPEGs and i am using the following code: credit goes to microsoft
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
private void SaveJPGWithCompressionSetting( Image image, string szFileName, long lCompression )
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, lCompression );
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
image.Save( szFileName, ici, eps );
}As far as I know, jpeg formats do NOT support transparency. Here you have some info about transparency in jpeg (and some other approaches to your problem) http://graphicssoft.about.com/b/2006/08/21/qa-transparent-jpeg.htm[^]. And here you have a list with transparency compatible image types http://en.wikipedia.org/wiki/Transparency_(graphic)[^]. Best of luck!
I have no smart signature yet...