sjd Posted February 8, 2006 Share Posted February 8, 2006 I've implemented code (in v2.1 base) to export a layer into a single RGB32 BMP. On import to layer, I can set the BitmapLayer Opacity to whatever I need. If the original saved layer had regions removed (set fully transparent ?) so the background is visible, these transparent regions are not reloaded (in Surface CopyFromBitmap). Is this a deficiency in .NET's Bitmap.Save methods or have I missed something the Surface class and how the GDI+ aliased bitmap is produced. Does deleting a region in a layer set that region Aplha values to 0, or is there a Transparency colour I've not yet spotted? regards SJD Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 11, 2006 Share Posted February 11, 2006 From what I've seen, Bitmap.Save does not save a bitmap's alpha channel. The BMP file format apprently doesn't really support it -- or, to be more exact, apparently none of the codecs that come with the system do. (yes, I agree it's odd) If you want to keep the transparency, I'd recommend saving with PNG or TGA. It's quite simple to do this in Paint.NET because we already have simple codecs in place for doing this. Some pseudo code ... Document just1layer = new Document(width, height); just1Layer.Layers.Add(theLayerYouWant); TgaFileType tft = new TgaFileType(); tft.Save(document, filename); Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
sjd Posted February 13, 2006 Author Share Posted February 13, 2006 Thanks Rick, I've also noticed other problems with BMP codecs. I currently use 16 bit BMPs to save 12bpp mono industrial camera dark current images. Because Format16bppGrayscale does not get saved/restored correctly (grrrr!), I use Format16bppRgb565. Details in the header cause Explorer to think its a 32 bit file, even though the BitmapData format is reported as 16 bit. If I create Format16bppRgb565 using C++ and create the headers Explorer is happy. I have not figured out a way to access the header (BITMAPINFOHEADER) in C# as yet. I was considering writing my own BMP Load and Save overrides derived from the Image class, as the Bitmap class is sealed. I'll look into using PNG instead. regards, SJD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.