Changeset 442 for GraphicTest
- Timestamp:
- Nov 22, 2012, 9:37:20 AM (12 years ago)
- Location:
- GraphicTest
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 7 7 GraphicTest.rc 8 8 GraphicTest.lps 9 GraphicTest.dbg
-
- Property svn:ignore
-
GraphicTest/GraphicTest.lpi
r356 r442 129 129 </CodeGeneration> 130 130 <Linking> 131 <Debugging> 132 <UseHeaptrc Value="True"/> 133 <UseExternalDbgSyms Value="True"/> 134 </Debugging> 131 135 <Options> 132 136 <Win32> -
GraphicTest/UDrawMethod.pas
r356 r442 1 1 unit UDrawMethod; 2 2 3 {$mode objfpc}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface 6 6 7 7 uses 8 Classes, SysUtils, StdCtrls,ExtCtrls, UPlatform, UFastBitmap, Graphics,8 Classes, SysUtils, ExtCtrls, UPlatform, UFastBitmap, Graphics, 9 9 LCLType, IntfGraphics, fpImage, GraphType, BGRABitmap, BGRABitmapTypes, 10 LclIntf , GL, GLExt, OpenGLContext;10 LclIntf{$IFDEF opengl}, GL, GLExt, OpenGLContext{$ENDIF}; 11 11 12 12 type … … 29 29 StepDuration: TDateTime; 30 30 PaintObject: TPaintObject; 31 {$IFDEF opengl} 31 32 OpenGLBitmap: Pointer; 32 33 OpenGLControl: TOpenGLControl; 33 34 TextureId: GLuint; 35 {$ENDIF} 34 36 procedure Init; virtual; 35 37 constructor Create; virtual; … … 114 116 end; 115 117 118 {$IFDEF opengl} 116 119 { TOpenGLMethod } 117 120 … … 135 138 procedure DrawFrame(FastBitmap: TFastBitmap); override; 136 139 end; 140 {$ENDIF} 137 141 138 142 const 139 DrawMethodClasses: array[0.. 10] of TDrawMethodClass = (143 DrawMethodClasses: array[0..{$IFDEF opengl}10{$ELSE}8{$ENDIF}] of TDrawMethodClass = ( 140 144 TCanvasPixels, TCanvasPixelsUpdateLock, TLazIntfImageColorsCopy, 141 145 TLazIntfImageColorsNoCopy, TBitmapRawImageData, TBitmapRawImageDataPaintBox, 142 TBitmapRawImageDataMove, TBGRABitmapPaintBox , TOpenGLMethod, TOpenGLPBOMethod,143 TDummyMethod);146 TBitmapRawImageDataMove, TBGRABitmapPaintBox{$IFDEF opengl}, TOpenGLMethod, TOpenGLPBOMethod{$ENDIF} 147 ,TDummyMethod); 144 148 145 149 implementation … … 208 212 end; 209 213 214 {$IFDEF opengl} 210 215 { TOpenGLPBOMethod } 211 216 … … 435 440 end; 436 441 442 {$ENDIF} 443 437 444 { TBGRABitmapPaintBox } 438 445 … … 460 467 var 461 468 X, Y: Integer; 462 P: P Integer;469 P: PCardinal; 463 470 begin 464 471 with FastBitmap do 465 472 for Y := 0 to Size.Y - 1 do begin 466 P := P Integer(BGRABitmap.ScanLine[Y]);473 P := PCardinal(BGRABitmap.ScanLine[Y]); 467 474 for X := 0 to Size.X - 1 do begin 468 475 P^ := NoSwapBRComponent(Pixels[X, Y]) or $ff000000; … … 492 499 var 493 500 Y, X: Integer; 494 PixelPtr: P Integer;495 RowPtr: P Integer;501 PixelPtr: PCardinal; 502 RowPtr: PCardinal; 496 503 P: TPixelFormat; 497 504 RawImage: TRawImage; … … 505 512 TempBitmap.BeginUpdate(False); 506 513 RawImage := TempBitmap.RawImage; 507 RowPtr := P Integer(RawImage.Data);514 RowPtr := PCardinal(RawImage.Data); 508 515 BytePerPixel := RawImage.Description.BitsPerPixel div 8; 509 516 BytePerRow := RawImage.Description.BytesPerLine; … … 538 545 var 539 546 Y, X: Integer; 540 PixelPtr: P Integer;541 RowPtr: P Integer;547 PixelPtr: PCardinal; 548 RowPtr: PCardinal; 542 549 P: TPixelFormat; 543 550 RawImage: TRawImage; … … 550 557 Bitmap.BeginUpdate(False); 551 558 RawImage := Bitmap.RawImage; 552 RowPtr := P Integer(RawImage.Data);559 RowPtr := PCardinal(RawImage.Data); 553 560 BytePerPixel := RawImage.Description.BitsPerPixel div 8; 554 561 BytePerRow := RawImage.Description.BytesPerLine; … … 643 650 try 644 651 Bitmap.BeginUpdate(True); 645 for X := 0 to Size.X- 1 do646 for Y := 0 to Size.Y- 1 do647 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])); 648 655 finally 649 656 Bitmap.EndUpdate(False); … … 664 671 begin 665 672 with FastBitmap do begin 666 for X := 0 to Size.X- 1 do667 for Y := 0 to Size.Y- 1 do668 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])); 669 676 end; 670 677 end; -
GraphicTest/UFastBitmap.pas
r356 r442 10 10 type 11 11 12 TFastBitmapPixel = Integer;12 TFastBitmapPixel = Cardinal; 13 13 (*TFastBitmapPixel = record 14 14 Blue: Byte; … … 70 70 end; 71 71 72 function SwapBRComponent(Value: Integer): Integer; inline;73 function NoSwapBRComponent(Value: Integer): Integer; inline;72 function SwapBRComponent(Value: Cardinal): Cardinal; inline; 73 function NoSwapBRComponent(Value: Cardinal): Cardinal; inline; 74 74 75 75 implementation 76 76 77 function SwapBRComponent(Value: Integer): Integer;77 function SwapBRComponent(Value: Cardinal): Cardinal; 78 78 begin 79 79 // Result := (Value and $00ff00) or ((Value shr 16) and $ff) or ((Value and $ff) shl 16); … … 83 83 end; 84 84 85 function NoSwapBRComponent(Value: Integer): Integer;85 function NoSwapBRComponent(Value: Cardinal): Cardinal; 86 86 begin 87 87 // Result := (Value and $00ff00) or ((Value shr 16) and $ff) or ((Value and $ff) shl 16); … … 211 211 for Y := 0 to (Size.Y div 2) - 1 do 212 212 for X := 0 to (Size.X div 3) - 1 do 213 Pixels[X + (I * (Size.X div 3)), Y] := 255 shl (I * 8);213 Pixels[X + (I * (Size.X div 3)), Y] := (255 shl (I * 8)) and $ffffff; 214 214 215 215 for Y := (Size.Y div 2) to Size.Y - 1 do 216 216 for X := 0 to Size.X - 1 do 217 Pixels[X, Y] := Random(256) or (Random(256) shl 16) or (Random(256) shl 8);217 Pixels[X, Y] := (Random(256) or (Random(256) shl 16) or (Random(256) shl 8)) and $ffffff; 218 218 end; 219 219 -
GraphicTest/UMainForm.pas
r338 r442 1 1 unit UMainForm; 2 2 3 {$mode Delphi}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface … … 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 9 ExtCtrls, StdCtrls, DateUtils, UPlatform, LCLType, IntfGraphics, fpImage, 10 Math, GraphType, Contnrs, LclIntf, Spin, UFastBitmap, UDrawMethod , GL,11 OpenGLContext;10 Math, GraphType, Contnrs, LclIntf, Spin, UFastBitmap, UDrawMethod 11 {$IFDEF opengl}, GL, OpenGLContext{$ENDIF}; 12 12 13 13 const … … 46 46 procedure Timer1Timer(Sender: TObject); 47 47 private 48 {$IFDEF opengl} 48 49 OpenGLControl1: TOpenGLControl; 49 50 TextureId: GLuint; 50 51 TextureData: Pointer; 52 {$ENDIF} 51 53 MethodIndex: Integer; 52 54 SingleTestActive: Boolean; 53 55 AllTestActive: Boolean; 54 56 procedure OpenGLControl1Resize(Sender: TObject); 57 {$IFDEF opengl} 55 58 procedure InitGL; 59 {$ENDIF} 56 60 procedure UpdateMethodList; 57 61 procedure UpdateInterface; … … 93 97 Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y); 94 98 99 {$IFDEF opengl} 95 100 OpenGLControl1 := TOpenGLControl.Create(Self); 96 101 with OpenGLControl1 do begin … … 103 108 end; 104 109 GetMem(TextureData, OpenGLControl1.Width * OpenGLControl1.Height * SizeOf(Integer)); 110 {$ENDIF} 105 111 106 112 DrawMethods := TObjectList.Create; … … 109 115 NewDrawMethod.Bitmap := Image1.Picture.Bitmap; 110 116 NewDrawMethod.PaintBox := PaintBox1; 117 {$IFDEF opengl} 111 118 NewDrawMethod.OpenGLBitmap := TextureData; 112 119 NewDrawMethod.OpenGLControl := OpenGLControl1; 120 {$ENDIF} 113 121 NewDrawMethod.Init; 114 122 DrawMethods.Add(NewDrawMethod); … … 191 199 begin 192 200 ListViewMethods.Clear; 193 FreeMem(TextureData, OpenGLControl1.Width * OpenGLControl1.Height);194 DrawMethods.Free;195 Scenes.Free;196 Bitmap.Free;201 {$IFDEF opengl}FreeMem(TextureData, OpenGLControl1.Width * OpenGLControl1.Height);{$ENDIF} 202 FreeAndNil(DrawMethods); 203 FreeAndNil(Scenes); 204 FreeAndNil(Bitmap); 197 205 end; 198 206 … … 232 240 procedure TMainForm.OpenGLControl1Resize(Sender: TObject); 233 241 begin 242 {$IFDEF opengl} 234 243 glViewport(0, 0, OpenGLControl1.Width, OpenGLControl1.Height); 235 end; 236 244 {$ENDIF} 245 end; 246 247 {$IFDEF opengl} 237 248 procedure TMainForm.InitGL; 238 249 begin … … 254 265 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 255 266 end; 267 {$ENDIF} 256 268 257 269 procedure TMainForm.UpdateMethodList; -
GraphicTest/UPlatform.pas
r200 r442 1 1 unit UPlatform; 2 2 3 {$mode Delphi}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface
Note:
See TracChangeset
for help on using the changeset viewer.