There is something I don't understand about
Microsoft. Take a look at the PixelFormat enumeration. Now
I can understand why there are several "Reserved" formats (some
super-secret GDI+ magic perhaps). But I don't understand why
there are formats like 48bppRgb, 64bppArgb, or 64bppPArgb. If you
open an image as one of these PixelFormats, it looks fine on a
PictureBox. But the BMP encoder (and I assume the other encoders)
absolutely mangles it when you try and save it (there are a bunch of
vertical scan lines and the colors get shifted).
Also, when you draw on an image in one of these formats,
weird things happen. I've noticed: when you draw a line
with Width = 1 and SmoothingMode = SmoothingMode.None at a certain angle, parts of
the image around the line go crazy. But only at certain line
angles and those line/Graphics settings. When drawing a rectangle
with the same settings (and those setting only), sometimes it draws the
rectangle but then draws white lines extending beyond it. Nothing
happens when drawing an ellipse. Why?
The "smaller" formats are fine though (16bppRgb565 and
16bppRgb555). The graphics object even uses advanced feathering
techniques to approximate a color that that format can't display.
When you try to create a Graphics object using
Graphics.FromImage(Bitmap) on a 16bppArgb1555 or 16bppGrayScale Bitmap
you get an "Out of memory" exception. Why can't GDI+ make a
16bppGrayScale kind of like the other 16bpp formats and just convert colors
into gray scale when using .DrawLine, .DrawRectangle, etc? It
converts invalid colors into "feathered" colors for 16bppRgb565 and
16bppRgb555...
Whenever you try to create a Graphics object from an
Indexed format (1bppIndexed, 4bppIndexed, 8bppIndexed, Indexed) you get
an exception that says "A Graphics object cannot be created from an
image that has an indexed pixel format." Why not? Can't it
just do like it does for 16bpp formats and find the closest valid color
for invalid colors?
I'm not even going to mention the PixelFormat.DontCare or
.Undefined formats... Or the fact that PixelFormat.Max ("The
maximum value for this enumeration.") equals 15 while 24bppRgb (the
standard format) equals 137224.
So my question is, why the inconsistency? It just
doesn't make sense... Why provide formats that you can't do
anything/much with?
That was my rant on the PixelFormat Enumeration, next week, don't miss "Other misc. GDI+ annoyances"...
Enter your message below
Sign in or Join us (it's free).