Open AndrewKaplanovsky opened 8 years ago
@AndrewKaplanovsky Yes, this is intended behavior. I have implemented the cast operator this way to ensure that the bitmap can be sufficiently processed further ahead.
Admittedly, the pixel format change may in some cases be overly intrusive, but I applied the "better-safe-than-sorry" approach here.
I should of course be more informative about this, perhaps in the wiki or something. I'll make sure to add some comments about it.
Is the pixel format change causing you problems, or were you primarily concerned of the undocumented behavior?
@anders9ustafsson, the problem is I store a mask, which I'm applying to an image, in a file. I know the format of the stored bmp is 1bpp, indexed color. But when I load it, instead of getting an indexed 1bpp image, I get the 32bpp image again :) So I need to convert it back to 1bpp, which is a very time consuming operation in my case. But anyway, thanks for letting me know, I've found another solution in my case, I just generate a matrix literal based on a mask image once and then use it in my app instead of a mask stored in a file.
Thank you very much for your help.
Hi Anders, so sorry for disturbing you again.
I have an image stored on a disk, .bmp file with PixelFormat = Format1bppIndexed. I try to load this file from Stream in my UWP application:
using (Stream stream = ResourcesUtils.GetResourceByID(ResourcesUtils.RES_BOARDMASK_20x20)) { Bitmap bmpMask = (Bitmap)System.Drawing.Image.FromStream(stream); ... }
When I check the PixelFormat of bmpMask, it's Format32bppArgb.
Is this a correct behavior or a bug in Shim.Drawing?