Here is the only method I can come up with since dbCreateImageFromMemblock (..) is broken:
int MakeBumpImage(int Image){
int iWidth=dbImageWidth(Image);
int iHeight=dbImageHeight(Image);
int MB=dbCreateMemblockFromImage(Image);
dbClearScreen();
for (int H=0;H<iHeight;H++){
for (int W=0;W<iWidth;W++){
DWORD C;
if (W>0) C=dbMemblockDword(MB,(H*iWidth+W-1)*4+12);
else C=dbMemblockDword(MB,(H*iWidth+iWidth-1)*4+12);
byte R=dbRGBB(C);
if (W<iWidth-1) C=dbMemblockDword(MB,(H*iWidth+W+1)*4+12);
else C=dbMemblockDword(MB,(H*iWidth+0)*4+12);
R=(R-dbRGBB(C)+255)/2;
if (H>0) C=dbMemblockDword(MB,((H-1)*iWidth+W)*4+12);
else C=dbMemblockDword(MB,((iHeight-1)*iWidth+W)*4+12);
byte G=dbRGBB(C);
if (H<iHeight-1) C=dbMemblockDword(MB,((H+1)*iWidth+W)*4+12);
else C=dbMemblockDword(MB,(W)*4+12);
G=(G-dbRGBB(C)+255)/2;
dbDot(W,H,dbRGB(byte(R),byte(G),255));
}
}
int B=dbGetImage(0,0,iWidth,iHeight);
dbDeleteMemblock(MB);
return B;
}
There MUST be a faster way. I was looking at dbLockPixels ( ), but I don't see how to take the pointer it gives me and write to the bitmap directly.
The fastest code is the code never written.