04-30-2007 11:37 PM
04-30-2007 11:59 PM
05-01-2007 02:15 PM
05-01-2007 09:06 PM
Hi Brandon,
I'm generating the bitmaps using the NewBitmap funtion. They are to be used for visual testing, and need to be cycled fast enough to effectivley create an animation. The image set need to be re-created on an arbirtary basis several times in the app as the test progresses through it's phases. After each phase, all exsisting bitmapIDs are discarded before creating new ones.
As I understand it, the functions you mentioned, AllocBitmapData& AllocBitmapDataEx would only be used when taking data from an exsisting bitmap.
Also, I did a few quick calculations of memory usage based on what the windows task manager reports. Reported change in memory usage was almost double what I calculated using x*y*pixelDepth. Does that sound right?
code snippet:
for (i=0;i<lastFrame;i++)
{
if (animBmp[i] != 0)
DiscardBitmap (animBmp[i]);
animBmp[i] = MakeBitmapTypeA (canvasSizeX, canvasSizeY, shapeFactor*i+PPC, /*...PORTION OMMITTED...*/);
}
int MakeBitmapTypeA (int canvasSizeX, int canvasSizeY, /*...PORTION OMMITTED...*/)
{
/*...PORTION OMMITTED...*/
for (absX=halfCanvasX;absX<canvasSizeX;absX++)
{
/*...PORTION OMMITTED...*/
for (absY=halfCanvasY;absY<canvasSizeY;absY++)
{
/*...PORTION OMMITTED...*/
/*All quadrants are identical, so generate one and mirror it into the other three*/
arrY = canvasSizeX*3*absY;
arrYinv = canvasSizeX*3*(canvasSizeY-absY-1);
baseIndex_SE = arrY + arrX; //+x,+y
baseIndex_NE = arrYinv + arrX; //+x,-y
baseIndex_NW = arrYinv + arrXinv; //-x,-y
baseIndex_SW = arrY + arrXinv; //-x,+y
arrPixels[baseIndex_SE] = arrPixels[baseIndex_NE] =
arrPixels[baseIndex_NW] = arrPixels[baseIndex_SW] = (colour&0xFF0000)>>16; //rr
arrPixels[baseIndex_SE+1] = arrPixels[baseIndex_NE+1] =
arrPixels[baseIndex_NW+1] = arrPixels[baseIndex_SW+1] = (colour&0xFF00)>>8; //gg
arrPixels[baseIndex_SE+2] = arrPixels[baseIndex_NE+2] =
arrPixels[baseIndex_NW+2] = arrPixels[baseIndex_SW+2] = (colour&0xFF); //bb
}
}
NewBitmap (canvasSizeX*3, 24, canvasSizeX, canvasSizeY, NULL, arrPixels, NULL, &bitmap);
//free up memory allocated to dynamic arrays
free (arrPixels);
return bitmap;
}
05-02-2007 04:45 PM
05-03-2007 02:42 AM
05-03-2007 05:40 PM