Today, the alpha channel of the modified image is used to implement the image reflection. However, when we test the image, we find that the 24-Bit Bitmap cannot implement the reflection, the reason is that there is no alpha channel for images with less than 24 digits, and there is no way to modify the alpha channel to implement image reflection. So I want to convert a 24-bit image into a 32-bit image. It can also have an alpha channel. In this case, some features of GDI + are used. Share the program.
Bool getbitmapdata (Bitmap * pbitmap, pixelformat, bitmapdata * Data)
{
Bitmap * BMP = pbitmap;
Gdiplus: rect R (0, 0, BMP-> getwidth (), BMP-> getheight ());
Uint pixelsize = getpixelformatsize (pixelformat );
Data-> stride = (pixelsize * R. Width + 31) & 0xffffffe0)> 3;
Data-> scan0 = (void *) New char [R. Height * Data-> stride];
BMP-> lockbits (& R, imagelockmoderead | imagelockmodeuserinputbuf,
Pixelformat, data );
BMP-> unlockbits (data );
// Delete BMP;
Return true;
}
// The pbitmap parameter is a 24-Bit Bitmap for transmitting objects.
Void change24to32 (Bitmap * pbitmap)
{
Bitmapdata data;
If (! Getbitmapdata (pbitmap, pixelformat32bppargb, & Data ))
Return;
If (pbitmap)
Delete pbitmap;
// Create a user-defined data bitmap object in 24-bit pixel format
Bitmap * BMP = new Bitmap (data. Width, Data. Height, Data. stride,
Data. pixelformat, (byte *) data. scan0 );
Pbitmap = BMP; // assign a new bitmap value to the transmitter.
}