Probably you are copying the data to another newly created bitmap. First you need a TUInt pointer to that addresses of bitmaps. This pointer may be 8bit or 16 bit or 24bit or 32bit depends on your logic of copying and number of times reading the memory. You increment the pointers and assign the value pointed by it.
Search this forum.. you will get more information.
Remember to lock bitmap's heap (LockHeap()) before starting to copy the data and unlock it (UnlockHeap()) after the copying is over. This way you assure, that internal bitmap data won't change while copying (for example due to memory reorganization).
If you want to copy the entire bitmap data, I would recommend useing Mem::Copy.
Also if you only want to take a part of the image, several calls to Mem::Copy, one per scanline, is usually a lot faster then a for loop. (as long as the scanline is longer then about 10 pixels or so)
This because Mem::Copy internally makes sure to use speed tweaks to copy sequential data as quick as possible.
The actuall copying of the data is no different from copying any other data really.
Make sure to call ScanLineLenght() or DataStride() (depening on OS version) to know how many bytes a scanline in the picture is. Because scanlines are always aligned to addresses divisible by four, a scanline is not always width*pixelsize long, but has 0-3 bytes padding too.
And the size of the image is scanlinelength * height, and not width*height*pixelsize ...
Forum posts: 45
Probably you are copying the data to another newly created bitmap. First you need a TUInt pointer to that addresses of bitmaps. This pointer may be 8bit or 16 bit or 24bit or 32bit depends on your logic of copying and number of times reading the memory. You increment the pointers and assign the value pointed by it.
Search this forum.. you will get more information.
Regards,
Tushar
Tushar Bhattacharyya
Forum posts: 64
Remember to lock bitmap's heap (LockHeap()) before starting to copy the data and unlock it (UnlockHeap()) after the copying is over. This way you assure, that internal bitmap data won't change while copying (for example due to memory reorganization).
Regards,
Damian
Confusion will be my epitaph..
Forum posts: 1246
Also if you only want to take a part of the image, several calls to Mem::Copy, one per scanline, is usually a lot faster then a for loop. (as long as the scanline is longer then about 10 pixels or so)
This because Mem::Copy internally makes sure to use speed tweaks to copy sequential data as quick as possible.
The actuall copying of the data is no different from copying any other data really.
Make sure to call ScanLineLenght() or DataStride() (depening on OS version) to know how many bytes a scanline in the picture is.
Because scanlines are always aligned to addresses divisible by four, a scanline is not always width*pixelsize long, but has 0-3 bytes padding too.
And the size of the image is scanlinelength * height, and not width*height*pixelsize ...