RSS/Atom feed Twitter
Site is read-only, email is disabled

Feature Request: Premultiplied Alpha for 32-bit Windows BMP

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

1 of 1 message available
Toggle history

Please log in to manage your subscriptions.

Feature Request: Premultiplied Alpha for 32-bit Windows BMP Matthew Turner 24 Dec 05:34
Matthew Turner
2012-12-24 05:34:37 UTC (almost 12 years ago)

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;
}
else
{
pixel.rgbBlue = blue;
pixel.rgbGreen = green;
pixel.rgbRed = red;
pixel.rgbReserved = alpha;
}
----------------------------------------

Thanks in advance!

Matthew Turner