Ignore:
Timestamp:
Nov 22, 2012, 9:37:20 AM (12 years ago)
Author:
chronos
Message:
  • Modified: OpenGL methods could be disabled by compiler define opengl.
  • Fixed: Range check error in pixel assignment. Type Cardinal used instead of type Integer.
Location:
GraphicTest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest

    • Property svn:ignore
      •  

        old new  
        77GraphicTest.rc
        88GraphicTest.lps
         9GraphicTest.dbg
  • GraphicTest/UDrawMethod.pas

    r356 r442  
    11unit UDrawMethod;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils, StdCtrls, ExtCtrls, UPlatform, UFastBitmap, Graphics,
     8  Classes, SysUtils, ExtCtrls, UPlatform, UFastBitmap, Graphics,
    99  LCLType, IntfGraphics, fpImage, GraphType, BGRABitmap, BGRABitmapTypes,
    10   LclIntf, GL, GLExt, OpenGLContext;
     10  LclIntf{$IFDEF opengl}, GL, GLExt, OpenGLContext{$ENDIF};
    1111
    1212type
     
    2929    StepDuration: TDateTime;
    3030    PaintObject: TPaintObject;
     31    {$IFDEF opengl}
    3132    OpenGLBitmap: Pointer;
    3233    OpenGLControl: TOpenGLControl;
    3334    TextureId: GLuint;
     35    {$ENDIF}
    3436    procedure Init; virtual;
    3537    constructor Create; virtual;
     
    114116  end;
    115117
     118  {$IFDEF opengl}
    116119  { TOpenGLMethod }
    117120
     
    135138    procedure DrawFrame(FastBitmap: TFastBitmap); override;
    136139  end;
     140  {$ENDIF}
    137141
    138142const
    139   DrawMethodClasses: array[0..10] of TDrawMethodClass = (
     143  DrawMethodClasses: array[0..{$IFDEF opengl}10{$ELSE}8{$ENDIF}] of TDrawMethodClass = (
    140144    TCanvasPixels, TCanvasPixelsUpdateLock, TLazIntfImageColorsCopy,
    141145    TLazIntfImageColorsNoCopy, TBitmapRawImageData, TBitmapRawImageDataPaintBox,
    142     TBitmapRawImageDataMove, TBGRABitmapPaintBox, TOpenGLMethod, TOpenGLPBOMethod,
    143     TDummyMethod);
     146    TBitmapRawImageDataMove, TBGRABitmapPaintBox{$IFDEF opengl}, TOpenGLMethod, TOpenGLPBOMethod{$ENDIF}
     147    ,TDummyMethod);
    144148
    145149implementation
     
    208212end;
    209213
     214{$IFDEF opengl}
    210215{ TOpenGLPBOMethod }
    211216
     
    435440end;
    436441
     442{$ENDIF}
     443
    437444{ TBGRABitmapPaintBox }
    438445
     
    460467var
    461468  X, Y: Integer;
    462   P: PInteger;
     469  P: PCardinal;
    463470begin
    464471  with FastBitmap do
    465472  for Y := 0 to Size.Y - 1 do begin
    466     P := PInteger(BGRABitmap.ScanLine[Y]);
     473    P := PCardinal(BGRABitmap.ScanLine[Y]);
    467474    for X := 0 to Size.X - 1 do begin
    468475      P^ := NoSwapBRComponent(Pixels[X, Y]) or $ff000000;
     
    492499var
    493500  Y, X: Integer;
    494   PixelPtr: PInteger;
    495   RowPtr: PInteger;
     501  PixelPtr: PCardinal;
     502  RowPtr: PCardinal;
    496503  P: TPixelFormat;
    497504  RawImage: TRawImage;
     
    505512      TempBitmap.BeginUpdate(False);
    506513      RawImage := TempBitmap.RawImage;
    507       RowPtr := PInteger(RawImage.Data);
     514      RowPtr := PCardinal(RawImage.Data);
    508515      BytePerPixel := RawImage.Description.BitsPerPixel div 8;
    509516      BytePerRow := RawImage.Description.BytesPerLine;
     
    538545var
    539546  Y, X: Integer;
    540   PixelPtr: PInteger;
    541   RowPtr: PInteger;
     547  PixelPtr: PCardinal;
     548  RowPtr: PCardinal;
    542549  P: TPixelFormat;
    543550  RawImage: TRawImage;
     
    550557      Bitmap.BeginUpdate(False);
    551558      RawImage := Bitmap.RawImage;
    552       RowPtr := PInteger(RawImage.Data);
     559      RowPtr := PCardinal(RawImage.Data);
    553560      BytePerPixel := RawImage.Description.BitsPerPixel div 8;
    554561      BytePerRow := RawImage.Description.BytesPerLine;
     
    643650  try
    644651    Bitmap.BeginUpdate(True);
    645     for X := 0 to Size.X - 1 do
    646       for Y := 0 to Size.Y - 1 do
    647         Bitmap.Canvas.Pixels[X, Y] := SwapBRComponent(Pixels[X, Y]);
     652    for Y := 0 to Size.Y - 1 do
     653      for X := 0 to Size.X - 1 do
     654        Bitmap.Canvas.Pixels[X, Y] := TColor(SwapBRComponent(Pixels[X, Y]));
    648655  finally
    649656    Bitmap.EndUpdate(False);
     
    664671begin
    665672  with FastBitmap do begin
    666     for X := 0 to Size.X - 1 do
    667       for Y := 0 to Size.Y - 1 do
    668         Bitmap.Canvas.Pixels[X, Y] := SwapBRComponent(Pixels[X, Y]);
     673    for Y := 0 to Size.Y - 1 do
     674      for X := 0 to Size.X - 1 do
     675        Bitmap.Canvas.Pixels[X, Y] := TColor(SwapBRComponent(Pixels[X, Y]));
    669676  end;
    670677end;
Note: See TracChangeset for help on using the changeset viewer.