Folks,

Unfortunately I don't know enough about pointers and the like, but I'm
trying to learn. People like Erwin Haid have provided me with HUGE help in
the past, so I'm hoping someone can come to my aid again. It might only take
someone with knowledge on this list a few minutes to fix what would
otherwise take me days. 

Considering the following two routines, the WriteToMonochromeBitmap function
writes the data far faster than the colour function because it writes the
image data to the new image line by line, not pixel by pixel. In the
WriteToColourBitmap function the target file is 24-bit - how do I replicate
the scanline by scanline method in this function ?

procedure WriteToColourBitmap(const ImageData: PChar; const Width, Height:
Integer);
var
  x, y, z, w, p: Integer;
  sl: PChar;
  pc: PRGBTriple;
begin
  { get pixel co-ordinate }
  p := AlignWord(Width * 3);

  { create bitmap }
  if Assigned(gbBitmap) then
  begin
    { write band }
    z := Height - 1;
    for y := 0 to z do
    begin
      sl := ImageData + y * p;
      w := Width - 1;
      for x := 0 to w do
      begin
        pc := PRGBTriple(sl + x * 3);
        gbBitmap.Canvas.Pixels[x, gbImageHeight + y] := RGB(pc.rgbtBlue,
pc.rgbtGreen, pc.rgbtRed);
      end;
    end;
  end;
end;

procedure WriteToMonochromeBitmap(const ImageData: PChar; const Width,
Height: Integer);
var
  x, y, z, w: Integer;
  sl: PChar;
  r: PByteArray;
begin
  { check bitmap }
  if Assigned(gbBitmap) then
  begin
    { calculate scanline length }
    w := Trunc(Width / 8);

    { write band }
    z := Height - 1;
    for y := 0 to z do
    begin
      sl := ImageData + (y * w);
      r := PByteArray(gbBitmap.Scanline[y]);
      for x := 0 to (w - 1) do
        r[x] := Byte(sl[x]);
    end;
  end;
end;

Many, many thanks in advance,
Darren

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.5 - Release Date: 29/03/2005
 


_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to