i am trying to convert the popular Split Image function from batfink, from dbpro to dgdk...
void SplitImage (int baseImage, int imgX, int imgY, int firstImg)
{
int imagesX, imagesY;
int rows, cols;
int img;
int offset1, offset2, offset3, offset4;
int imgDword;
int NewByte;
int memNo = 1;
dbMakeMemblockFromImage (memNo,baseImage);
DWORD iW = (dbMemblockDword (memNo,0));
DWORD iH = (dbMemblockDword (memNo,4));
DWORD iD = (dbMemblockDword (memNo,8));
DWORD imgWidth = iW / imgX;
DWORD imgHeight = iH / imgY;
int mbSize = ((imgWidth * imgHeight) + 3) * 4;
int memNo2 = 2;
dbMakeMemblock (memNo2, mbSize);
dbWriteMemblockDword (memNo2,0,imgWidth);
dbWriteMemblockDword (memNo2,4,imgHeight);
dbWriteMemblockDword (memNo2,8,iD);
for (imagesY=1; imagesY<imgY+1; imagesY++)
{
for (imagesX=1;imagesX<imgX+1;imagesX++)
{
img = ((imagesY -1) * imgX) + imagesX;
NewByte = 12;
for (rows=1;rows<imgHeight-1;rows++)
{
for (cols=1;cols<imgWidth+1;cols++)
{
offset1 = (imagesY - 1) * imgWidth * imgHeight * imgX;
offset2 = (iW * (rows - 1));
offset3 = imgWidth * (imagesX - 1);
offset4 = cols - 1;
imgDword = (offset1 + offset2 + offset3 + offset4 + 3) * 4;
dbWriteMemblockDword (memNo2,NewByte, dbMemblockDword(memNo,imgDword));
NewByte=NewByte+4;
}
}
NewByte = 12;
dbMakeImageFromMemblock ((img + firstImg - 1),memNo2);
}
}
dbDeleteMemblock (memNo);
dbDeleteMemblock (memNo2);
}
i am having some problems with defining the proper status of the variables used, especiall iW iH iD imgWidth & imgHeight. if i set these to int the function works but it produces hazardous results and vc++ exe crashes at random. if i set them to dword all works fine.
my question is, anyone can check the proper defined status of the variables and let me know if they are properly set?
thanks a lot