Board index » delphi » Copy Bitmap to one array?

Copy Bitmap to one array?

I am using the following method to copy a bitmap to a continues memory
array.
for i:=0 to Bitmap.Height-1 do
  Move(Bitmap.ScanLine[i]^, BitmapArray[i, 0], Bitmap.Width*BytesPerPixel)

So I can use BitmapArray as one pice of bitmap data.

My question is can I do the following instead of upper sample?
  Move(Bitmap.ScanLine[0]^, BitmapArray[0, 0],
Bitmap.Height*Bitmap.Width*BytesPerPixel)
If NO, can anyone tell me how to get a continus memory of a bitmap (as fast
as posible)?
(I want to send a Bitmap to another PC via network as fast as posible)

Thank you!

Samson Fu

 

Re:Copy Bitmap to one array?


Quote
"Samson Fu" <samso...@hotmail.com> wrote in message news:8i2qne$6d65@bornews.borland.com...
> I am using the following method to copy a bitmap to a continues memory
> array.
> for i:=0 to Bitmap.Height-1 do
>   Move(Bitmap.ScanLine[i]^, BitmapArray[i, 0], Bitmap.Width*BytesPerPixel)

> So I can use BitmapArray as one pice of bitmap data.

> My question is can I do the following instead of upper sample?
>   Move(Bitmap.ScanLine[0]^, BitmapArray[0, 0],
> Bitmap.Height*Bitmap.Width*BytesPerPixel)

You might take a look at the subsection "Copy Raw Data to Scanline Area" in
the Optimization section of:
http://www.efg2.com/Lab/ImageProcessing/Scanline.htm

Quote
> If NO, can anyone tell me how to get a continus memory of a bitmap (as fast
> as posible)?
> (I want to send a Bitmap to another PC via network as fast as posible)

My guess is that your network transfer is much slower than your memory accesses.
You can save some time by optimizing your scanline accesses, but even if the
memory accesses were infinitely fast, you still have slow network transfers
compared to memory accesses.

Amdahl's Law is at work.
--
efg

Earl F. Glynn     E-mail:  EarlGl...@att.net
Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

Re:Copy Bitmap to one array?


Hello there, maybe this is what youre looking for:

 Type
          TRGBTripleArray : Array [0..1] of TRGBTriple;
          pTRGBTripleArray: ^TRGBTripleArray;
 Var
         BitmapArray : Array of pTRGBTriple;
         Bitmap : TBitmap;
         x : integer;
begin
SetLength(BitmapArray,Bitmap.Width-1);
for y:=0 to Length(BitmapArray) do BitmapArray[y]:=Bitmap.Scanline[y];
end;

Quote
"Samson Fu" <samso...@hotmail.com> wrote in message

news:8i2qne$6d65@bornews.borland.com...
Quote
> I am using the following method to copy a bitmap to a continues memory
> array.
> for i:=0 to Bitmap.Height-1 do
>   Move(Bitmap.ScanLine[i]^, BitmapArray[i, 0], Bitmap.Width*BytesPerPixel)

> So I can use BitmapArray as one pice of bitmap data.

> My question is can I do the following instead of upper sample?
>   Move(Bitmap.ScanLine[0]^, BitmapArray[0, 0],
> Bitmap.Height*Bitmap.Width*BytesPerPixel)
> If NO, can anyone tell me how to get a continus memory of a bitmap (as
fast
> as posible)?
> (I want to send a Bitmap to another PC via network as fast as posible)

> Thank you!

> Samson Fu

Re:Copy Bitmap to one array?


use a Device Independent Bitmap if you want one big array of data....

Quote
Samson Fu <samso...@hotmail.com> wrote in message

news:8i2qne$6d65@bornews.borland.com...
Quote
> I am using the following method to copy a bitmap to a continues memory
> array.
> for i:=0 to Bitmap.Height-1 do
>   Move(Bitmap.ScanLine[i]^, BitmapArray[i, 0], Bitmap.Width*BytesPerPixel)

> So I can use BitmapArray as one pice of bitmap data.

> My question is can I do the following instead of upper sample?
>   Move(Bitmap.ScanLine[0]^, BitmapArray[0, 0],
> Bitmap.Height*Bitmap.Width*BytesPerPixel)

> If NO, can anyone tell me how to get a continus memory of a bitmap (as
fast
> as posible)?
> (I want to send a Bitmap to another PC via network as fast as posible)

> Thank you!

> Samson Fu

Re:Copy Bitmap to one array?


Hello there again...ehh it seems like Ive made a typo....
the correct version would be like this:

 Type
          TRGBTripleArray : Array [0..1] of TRGBTriple;
          pRGBTripleArray: ^TRGBTripleArray;
 Var
         BitmapArray : Array of pRGBTripleArray;
         Bitmap : TBitmap;
         x : integer;
begin
SetLength(BitmapArray,Bitmap.Width-1);
for y:=0 to Length(BitmapArray) do BitmapArray[y]:=Bitmap.Scanline[y];
end;

Quote
"Michael Hansen" <dyster_...@hotmail.com> wrote in message

news:8i3bi2$egt$1@news.inet.tele.dk...
Quote
> Hello there, maybe this is what youre looking for:

>  Type
>           TRGBTripleArray : Array [0..1] of TRGBTriple;
>           pTRGBTripleArray: ^TRGBTripleArray;
>  Var
>          BitmapArray : Array of pTRGBTriple;
>          Bitmap : TBitmap;
>          x : integer;
> begin
> SetLength(BitmapArray,Bitmap.Width-1);
> for y:=0 to Length(BitmapArray) do BitmapArray[y]:=Bitmap.Scanline[y];
> end;

> "Samson Fu" <samso...@hotmail.com> wrote in message
> news:8i2qne$6d65@bornews.borland.com...
> > I am using the following method to copy a bitmap to a continues memory
> > array.
> > for i:=0 to Bitmap.Height-1 do
> >   Move(Bitmap.ScanLine[i]^, BitmapArray[i, 0],

Bitmap.Width*BytesPerPixel)

- Show quoted text -

Quote

> > So I can use BitmapArray as one pice of bitmap data.

> > My question is can I do the following instead of upper sample?
> >   Move(Bitmap.ScanLine[0]^, BitmapArray[0, 0],
> > Bitmap.Height*Bitmap.Width*BytesPerPixel)
> > If NO, can anyone tell me how to get a continus memory of a bitmap (as
> fast
> > as posible)?
> > (I want to send a Bitmap to another PC via network as fast as posible)

> > Thank you!

> > Samson Fu

Other Threads