## wb_get_image_data

string wb_get_image_data (int image [int compress4to3])

Returns a string of data containing a copy of the internal true-color representation of the given image. The image handle must have been obtained with wb_create_image(), wb_create_mask() or wb_load_image(). Returns `TRUE` on success or `FALSE` if an error occurs.

If compress4to3 is TRUE, every fourth byte of the original 32-bit data is skipped, yielding a RGB (24-bit) data string. This is required for image libraries such as FreeImage (click here for more information).

This function is useful to read the image pixels directly or to convert an image to another format like PNG, JPEG, or GIF using a foreign library. For more information consult the Windows API documentation.

Example

`<? // This example has no main window: it is a console application include_once("../include/winbinder.php"); include_once("../include/fi/freeimage.inc.php"); // Create a true-color bitmap and draw something on it $bmp = wb_create_image(120, 20); wb_draw_rect($bmp, 0, 0, 120, 20, 0xA0F0E0); $font = wb_create_font("Arial", 8); wb_draw_text($bmp, "This is a test image.", 0, 0, 120, 20, $font, WBC_CENTER); // Copy the bitmap color data to a DIB and save it as a PNG file $pixeldata = wb_get_image_data($bmp, true); $dib = FreeImage_Allocate(120, 20, 24); wb_poke(FreeImage_GetBits($dib), $pixeldata); FreeImage_Save(FIF_PNG, $dib, "test.png"); // Cleanup wb_destroy_image($bmp); FreeImage_Unload($dib); ?>`

See also

wb_create_image
wb_create_mask
wb_load_image
Image functions
Low-level functions