I'm sure this has been discussed many times, but since I'm unable to show search results with more than 100 records, I have to ask this again
I need to write to an image at runtime (terrain texture) and found dbWriteImage(), which seems to be able to do what I need.
However, it does not seem to address correctly the single pixels. In the following sample, I would expect to draw red coloured pixels every 4 pixels, evenly spaced all over. Instead it produces vertical lines, and would fill only about 1/4 of the whole image.
Also it seems, the Y axis goes not from top to bottom, but from left to right.
For me, any kind of addressing the pixel coordinates is fine, but it should be reliable. I tried also to use direct memory access with dbGetImageData/dbSetImageData, but it has other problems, so I'm falling back to dbWriteImage().
Can somebody link me please to a page where the usage of this function is explained, or to a good alternative?
Thanks,
Giovanni
void WriteImage()
{
int x;
int y;
// Create test image
dbCreateBitmap(1, 16, 16);
dbMakeMemblockFromBitmap(1, 1);
dbDeleteBitmap(1);
dbMakeImageFromMemblock(1, 1);
dbDeleteMemblock(1);
// Write to image
dbLockImage(1);
for(y = 0; y < 16; y += 4)
{
for(x = 0; x < 16; x += 4)
{
// void dbWriteImage(int iID, int iX, int iY, int iA, int iR, int iG, int iB);
dbWriteImage(1, x, y, 0, 255, 0, 0);
}
}
dbUnlockImage(1);
// Save test image
dbSaveImage("test.bmp", 1);
dbDeleteImage(1);
}