Ignore:
Timestamp:
Mar 18, 2011, 9:34:42 AM (13 years ago)
Author:
george
Message:
  • Fixed: Red and Blue color components swaping.
  • Fixed: PageControl tabs auto switching.
  • Modified: TFastBitmap class replaced by similar one which use pixels data as one memory block instead of array of arrays. With only one memory block optimization using FillChar and Move can be used.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/UDrawMethod.pas

    r203 r206  
    1111
    1212type
     13  TPaintObject = (poImage, poPaintBox, poOpenGL);
    1314
    1415  { TDrawMethod }
     
    2526    Terminated: Boolean;
    2627    FrameDuration: TDateTime;
     28    PaintObject: TPaintObject;
    2729    constructor Create; virtual;
    2830    destructor Destroy; override;
     
    113115  Caption := 'TBGRABitmap PaintBox';
    114116  BGRABitmap := TBGRABitmap.Create(0, 0);
     117  PaintObject := poPaintBox;
    115118end;
    116119
     
    124127var
    125128  X, Y: Integer;
    126   P: PBGRAPixel;
     129  P: PInteger;
    127130begin
    128131  with FastBitmap do
    129132  for Y := 0 to Size.Y - 1 do begin
    130     P := BGRABitmap.ScanLine[Y];
     133    P := PInteger(BGRABitmap.ScanLine[Y]);
    131134    for X := 0 to Size.X - 1 do begin
    132       P^.red := Pixels[X, Y];
     135      P^ := NoSwapBRComponent(Pixels[X, Y]);
     136      (*P^.red := Pixels[X, Y];
    133137      P^.green := Pixels[X, Y];
    134138      P^.blue := Pixels[X, Y];
    135       P^.alpha := 255;
     139      P^.alpha := 255; *)
    136140      Inc(P);
    137141    end;
    138142  end;
    139   BGRABitmap.InvalidateBitmap; // changed by direct access
    140   //BGRABitmap.Draw(Bitmap.Canvas, 0, 0, False);
     143  //BGRABitmap.InvalidateBitmap; // changed by direct access
     144  //BGRABitmap.Draw(Bitmap.Canvas, 0, 0, True);
    141145  BGRABitmap.Draw(PaintBox.Canvas, 0, 0, True);
     146//  Bitmap.RawImage.Ass
    142147end;
    143148
     
    148153  inherited;
    149154  Caption := 'TBitmap.RawImage.Data PaintBox';
     155  PaintObject := poPaintBox;
    150156end;
    151157
     
    154160  Y, X: Integer;
    155161  PixelPtr: PInteger;
     162  RowPtr: PInteger;
    156163  P: TPixelFormat;
    157164  RawImage: TRawImage;
    158165  BytePerPixel: Integer;
     166  BytePerRow: Integer;
    159167  hPaint, hBmp: HDC;
    160168begin
     
    164172      TempBitmap.BeginUpdate(False);
    165173      RawImage := TempBitmap.RawImage;
    166       PixelPtr := PInteger(RawImage.Data);
     174      RowPtr := PInteger(RawImage.Data);
    167175      BytePerPixel := RawImage.Description.BitsPerPixel div 8;
    168       for X := 0 to Size.X - 1 do
    169         for Y := 0 to Size.Y - 1 do begin
    170           PixelPtr^ := Pixels[X, Y] * $010101;
     176      BytePerRow := RawImage.Description.BytesPerLine;
     177      for Y := 0 to Size.Y - 1 do begin
     178        PixelPtr := RowPtr;
     179        for X := 0 to Size.X - 1 do begin
     180          PixelPtr^ := Pixels[X, Y];
    171181          Inc(PByte(PixelPtr), BytePerPixel);
    172182        end;
     183        Inc(PByte(RowPtr), BytePerRow);
     184      end;
    173185    finally
    174186      TempBitmap.EndUpdate(False);
     
    190202
    191203procedure TBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap);
     204type
     205  TFastBitmapPixelComponents = packed record
     206  end;
    192207var
    193208  Y, X: Integer;
     
    210225        PixelPtr := RowPtr;
    211226        for X := 0 to Size.X - 1 do begin
    212           PixelPtr^ := Pixels[X, Y] * $010101;
     227          PixelPtr^ := Pixels[X, Y];
    213228          Inc(PByte(PixelPtr), BytePerPixel);
    214229        end;
     
    248263    for X := 0 to Size.X - 1 do
    249264      for Y := 0 to Size.Y - 1 do
    250         TempIntfImage.Colors[X, Y] := TColorToFPColor(Pixels[X, Y] * $010101);
     265        TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y]));
    251266    Bitmap.LoadFromIntfImage(TempIntfImage);
    252267  end;
     
    277292    for X := 0 to Size.X - 1 do
    278293      for Y := 0 to Size.Y - 1 do
    279         TempIntfImage.Colors[X, Y] := TColorToFPColor(Pixels[X, Y] * $010101);
     294        TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y]));
    280295    Bitmap.LoadFromIntfImage(TempIntfImage);
    281296  end;
     
    299314    for X := 0 to Size.X - 1 do
    300315      for Y := 0 to Size.Y - 1 do
    301         Bitmap.Canvas.Pixels[X, Y] := Pixels[X, Y] * $010101;
     316        Bitmap.Canvas.Pixels[X, Y] := SwapBRComponent(Pixels[X, Y]);
    302317  finally
    303318    Bitmap.EndUpdate(False);
     
    320335    for X := 0 to Size.X - 1 do
    321336      for Y := 0 to Size.Y - 1 do
    322         Bitmap.Canvas.Pixels[X, Y] := Pixels[X, Y] * $010101;
     337        Bitmap.Canvas.Pixels[X, Y] := SwapBRComponent(Pixels[X, Y]);
    323338  end;
    324339end;
Note: See TracChangeset for help on using the changeset viewer.