How to copy DataAddress()

Login to reply to this topic.
Thu, 2007-02-08 12:22
Joined: 2004-07-12
Forum posts: 123
helooz,

how can i copy the data pointed to by the pointer from bitmap.DataAddress()??

thanx

Thu, 2007-02-08 15:51
Joined: 2006-12-15
Forum posts: 45
Re: How to copy DataAddress()
Hi,

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

Fri, 2007-02-09 08:45
Joined: 2006-05-10
Forum posts: 64
Re: How to copy DataAddress()
Hi,

  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..

Mon, 2007-02-12 13:31
Joined: 2004-11-29
Forum posts: 1246
Re: How to copy DataAddress()
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 ...
  • Login to reply to this topic.