Hello,
in my demo project i want to load an extern bitmap which i saved as an binary file. When implementing the following code i recognized some difference in Bitmap creation. When calling EwCreateBitmap in Windows the Bitmap is aligned to 4 Byte (empty pixels added) and with OpenGL the is no alignment.
I do not want to make a conversion while loading the Bitmap. Is it possible to influence the pixel alignment?
Another problem i've got is that under Linux the error 137 ("Failed to lock the surface for direct memory access.") occurs. With Windows i do not have any problem. Maybe it has to do something with the difference in Bitmap creation?!
XHandle DeviceDriver::create_xbitmap(myBITMAP Bitmap)
{
XBitmap *xBitmap;
XBitmapLock *xBitmapLock;
XPoint xSize;
xSize.X = Bitmap.width;
xSize.Y = Bitmap.height;
/* create EW Bitmap */
xBitmap = EwCreateBitmap(EW_PIXEL_FORMAT_NATIVE, xSize, 0, 1);
if (!xBitmap)
{
printf("Could not create EW Bitmap \n");
return 0;
}
/* Lock the entire bitmap for the write only operation */
xBitmapLock = EwLockBitmap(xBitmap, 0, EwNewRect(0, 0, xSize.X, xSize.Y), 0, 1);
uint32_t offset = (xBitmapLock->Pitch1Y >> 2) - xSize.X; // different with Win32, OpenGL
/* Get the pointer to the bitmap pixel memory */
memcpy(xBitmapLock->Pixel1, Bitmap.image, Bitmap.size);
/* finally, unlock the bitmap */
EwUnlockBitmap(xBitmapLock);
return (XHandle)xBitmap;
}