[Gimp-developer] Feature Request: Premultiplied Alpha for 32-bit Windows BMP

Hi all,

I write to request a feature addition to the "Windows BMP image (*.BMP)" exporter in GIMP.

The exporter currently (GIMP 2.8.2) allows the user to select from a variety of sub-formats. One such sub-format is "A8 R8 G8 B8", which stores an alpha channel in the unused/reserved byte of each pixel's RGBQUAD structure.

This may be suitable and convienient when using BMP as an interchange format. However, Windows application developers like myself need to create 32-bit BMP images with premultiplied alpha. This is necessary because the Windows GDI functions that perform alpha blending of bitmaps expect the RGB channels to be premultiplied by the alpha value.

I therefore request the addition of a "premultiplied" variant of "A8 R8 G8 B8".

I believe this feature should be easy enough to add. The "Export Image as BMP" dialog window can be expanded to include an additional radio button called, say, "A8 R8 G8 B8 (Premultiplied)". When the user selects this option, the pixels should be written using an algorithm along the following lines:

if (premultiply)
   // These calculations assume integers in the range 0..255

   pixel.rgbBlue = blue * alpha / 255;
   pixel.rgbGreen = green * alpha / 255;
   pixel.rgbRed = red * alpha / 255;
   pixel.rgbReserved = alpha;
   pixel.rgbBlue = blue;
   pixel.rgbGreen = green;
   pixel.rgbRed = red;
   pixel.rgbReserved = alpha;

Thanks in advance!

Matthew Turner

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]