Changeset 202
- Timestamp:
- Mar 17, 2011, 9:38:21 AM (14 years ago)
- Location:
- GraphicTest
- Files:
-
- 18 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/GraphicTest.lpi
r201 r202 39 39 </Item2> 40 40 </RequiredPackages> 41 <Units Count="2 0">41 <Units Count="27"> 42 42 <Unit0> 43 43 <Filename Value="GraphicTest.lpr"/> … … 47 47 <TopLine Value="1"/> 48 48 <CursorPos X="17" Y="3"/> 49 <UsageCount Value=" 28"/>49 <UsageCount Value="32"/> 50 50 </Unit0> 51 51 <Unit1> … … 58 58 <EditorIndex Value="0"/> 59 59 <WindowIndex Value="0"/> 60 <TopLine Value="10 4"/>61 <CursorPos X=" 76" Y="111"/>62 <UsageCount Value=" 28"/>60 <TopLine Value="107"/> 61 <CursorPos X="1" Y="122"/> 62 <UsageCount Value="32"/> 63 63 <Loaded Value="True"/> 64 64 <LoadedDesigner Value="True"/> … … 70 70 <TopLine Value="1"/> 71 71 <CursorPos X="42" Y="22"/> 72 <UsageCount Value="1 9"/>72 <UsageCount Value="18"/> 73 73 </Unit2> 74 74 <Unit3> … … 76 76 <IsPartOfProject Value="True"/> 77 77 <UnitName Value="UPlatform"/> 78 <EditorIndex Value=" 4"/>78 <EditorIndex Value="11"/> 79 79 <WindowIndex Value="0"/> 80 80 <TopLine Value="43"/> 81 81 <CursorPos X="1" Y="1"/> 82 <UsageCount Value=" 28"/>82 <UsageCount Value="32"/> 83 83 <Loaded Value="True"/> 84 84 </Unit3> … … 89 89 <TopLine Value="244"/> 90 90 <CursorPos X="49" Y="262"/> 91 <UsageCount Value="1 3"/>91 <UsageCount Value="12"/> 92 92 </Unit4> 93 93 <Unit5> … … 97 97 <TopLine Value="121"/> 98 98 <CursorPos X="57" Y="142"/> 99 <UsageCount Value="1 3"/>99 <UsageCount Value="12"/> 100 100 </Unit5> 101 101 <Unit6> … … 104 104 <TopLine Value="85"/> 105 105 <CursorPos X="10" Y="102"/> 106 <UsageCount Value="1 3"/>106 <UsageCount Value="12"/> 107 107 </Unit6> 108 108 <Unit7> … … 111 111 <TopLine Value="153"/> 112 112 <CursorPos X="1" Y="160"/> 113 <UsageCount Value="1 3"/>113 <UsageCount Value="12"/> 114 114 </Unit7> 115 115 <Unit8> … … 119 119 <TopLine Value="1282"/> 120 120 <CursorPos X="15" Y="1299"/> 121 <UsageCount Value="1 3"/>121 <UsageCount Value="12"/> 122 122 </Unit8> 123 123 <Unit9> … … 126 126 <TopLine Value="546"/> 127 127 <CursorPos X="11" Y="553"/> 128 <UsageCount Value="1 3"/>128 <UsageCount Value="12"/> 129 129 </Unit9> 130 130 <Unit10> … … 133 133 <TopLine Value="389"/> 134 134 <CursorPos X="1" Y="411"/> 135 <UsageCount Value=" 10"/>135 <UsageCount Value="9"/> 136 136 </Unit10> 137 137 <Unit11> … … 140 140 <TopLine Value="444"/> 141 141 <CursorPos X="1" Y="461"/> 142 <UsageCount Value="1 3"/>142 <UsageCount Value="12"/> 143 143 </Unit11> 144 144 <Unit12> … … 147 147 <TopLine Value="14"/> 148 148 <CursorPos X="24" Y="21"/> 149 <UsageCount Value="1 3"/>149 <UsageCount Value="12"/> 150 150 </Unit12> 151 151 <Unit13> … … 154 154 <TopLine Value="313"/> 155 155 <CursorPos X="24" Y="316"/> 156 <UsageCount Value="1 3"/>156 <UsageCount Value="12"/> 157 157 </Unit13> 158 158 <Unit14> … … 161 161 <TopLine Value="149"/> 162 162 <CursorPos X="3" Y="151"/> 163 <UsageCount Value="1 3"/>163 <UsageCount Value="12"/> 164 164 </Unit14> 165 165 <Unit15> … … 169 169 <TopLine Value="171"/> 170 170 <CursorPos X="3" Y="188"/> 171 <UsageCount Value="1 2"/>171 <UsageCount Value="11"/> 172 172 </Unit15> 173 173 <Unit16> … … 176 176 <TopLine Value="300"/> 177 177 <CursorPos X="3" Y="317"/> 178 <UsageCount Value=" 10"/>178 <UsageCount Value="9"/> 179 179 </Unit16> 180 180 <Unit17> … … 182 182 <IsPartOfProject Value="True"/> 183 183 <UnitName Value="UDrawMethod"/> 184 <EditorIndex Value=" 3"/>185 <WindowIndex Value="0"/> 186 <TopLine Value="1 52"/>187 <CursorPos X=" 13" Y="162"/>188 <UsageCount Value="2 2"/>184 <EditorIndex Value="6"/> 185 <WindowIndex Value="0"/> 186 <TopLine Value="1"/> 187 <CursorPos X="33" Y="15"/> 188 <UsageCount Value="26"/> 189 189 <Loaded Value="True"/> 190 190 </Unit17> … … 193 193 <IsPartOfProject Value="True"/> 194 194 <UnitName Value="UFastBitmap"/> 195 <EditorIndex Value=" 2"/>195 <EditorIndex Value="5"/> 196 196 <WindowIndex Value="0"/> 197 197 <TopLine Value="1"/> 198 <CursorPos X=" 30" Y="45"/>199 <UsageCount Value="2 2"/>198 <CursorPos X="20" Y="20"/> 199 <UsageCount Value="26"/> 200 200 <Loaded Value="True"/> 201 201 </Unit18> 202 202 <Unit19> 203 203 <Filename Value="../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/rasterimage.inc"/> 204 <EditorIndex Value="2"/> 205 <WindowIndex Value="0"/> 206 <TopLine Value="504"/> 207 <CursorPos X="1" Y="521"/> 208 <UsageCount Value="12"/> 209 <Loaded Value="True"/> 210 </Unit19> 211 <Unit20> 212 <Filename Value="bgrabitmap/bgradefaultbitmap.pas"/> 213 <UnitName Value="BGRADefaultBitmap"/> 214 <EditorIndex Value="3"/> 215 <WindowIndex Value="0"/> 216 <TopLine Value="224"/> 217 <CursorPos X="15" Y="237"/> 218 <UsageCount Value="11"/> 219 <Loaded Value="True"/> 220 </Unit20> 221 <Unit21> 222 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 223 <UnitName Value="BGRAWinBitmap"/> 224 <EditorIndex Value="4"/> 225 <WindowIndex Value="0"/> 226 <TopLine Value="169"/> 227 <CursorPos X="1" Y="190"/> 228 <UsageCount Value="11"/> 229 <Loaded Value="True"/> 230 </Unit21> 231 <Unit22> 232 <Filename Value="../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/extctrls.pp"/> 233 <UnitName Value="ExtCtrls"/> 204 234 <EditorIndex Value="1"/> 205 235 <WindowIndex Value="0"/> 206 <TopLine Value=" 292"/>207 <CursorPos X=" 1" Y="305"/>236 <TopLine Value="584"/> 237 <CursorPos X="3" Y="597"/> 208 238 <UsageCount Value="10"/> 209 239 <Loaded Value="True"/> 210 </Unit19> 240 </Unit22> 241 <Unit23> 242 <Filename Value="../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/winapih.inc"/> 243 <EditorIndex Value="9"/> 244 <WindowIndex Value="0"/> 245 <TopLine Value="32"/> 246 <CursorPos X="10" Y="45"/> 247 <UsageCount Value="10"/> 248 <Loaded Value="True"/> 249 </Unit23> 250 <Unit24> 251 <Filename Value="../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/winapi.inc"/> 252 <EditorIndex Value="10"/> 253 <WindowIndex Value="0"/> 254 <TopLine Value="51"/> 255 <CursorPos X="3" Y="53"/> 256 <UsageCount Value="10"/> 257 <Loaded Value="True"/> 258 </Unit24> 259 <Unit25> 260 <Filename Value="../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/graphics.pp"/> 261 <UnitName Value="Graphics"/> 262 <EditorIndex Value="8"/> 263 <WindowIndex Value="0"/> 264 <TopLine Value="1081"/> 265 <CursorPos X="15" Y="1094"/> 266 <UsageCount Value="10"/> 267 <Loaded Value="True"/> 268 </Unit25> 269 <Unit26> 270 <Filename Value="../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/rtl/objpas/classes/classesh.inc"/> 271 <EditorIndex Value="7"/> 272 <WindowIndex Value="0"/> 273 <TopLine Value="1883"/> 274 <CursorPos X="10" Y="1896"/> 275 <UsageCount Value="10"/> 276 <Loaded Value="True"/> 277 </Unit26> 211 278 </Units> 212 <JumpHistory Count=" 30" HistoryIndex="29">279 <JumpHistory Count="29" HistoryIndex="28"> 213 280 <Position1> 214 <Filename Value=" UDrawMethod.pas"/>215 <Caret Line=" 94" Column="8" TopLine="72"/>281 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 282 <Caret Line="177" Column="1" TopLine="165"/> 216 283 </Position1> 217 284 <Position2> 218 <Filename Value=" UDrawMethod.pas"/>219 <Caret Line=" 81" Column="20" TopLine="68"/>285 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 286 <Caret Line="179" Column="1" TopLine="165"/> 220 287 </Position2> 221 288 <Position3> 222 <Filename Value=" UDrawMethod.pas"/>223 <Caret Line=" 29" Column="24" TopLine="13"/>289 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 290 <Caret Line="180" Column="1" TopLine="165"/> 224 291 </Position3> 225 292 <Position4> 226 <Filename Value=" UDrawMethod.pas"/>227 <Caret Line=" 36" Column="1" TopLine="16"/>293 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 294 <Caret Line="181" Column="1" TopLine="168"/> 228 295 </Position4> 229 296 <Position5> 230 <Filename Value=" UDrawMethod.pas"/>231 <Caret Line=" 61" Column="1" TopLine="40"/>297 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 298 <Caret Line="183" Column="1" TopLine="168"/> 232 299 </Position5> 233 300 <Position6> 234 <Filename Value=" UDrawMethod.pas"/>235 <Caret Line=" 68" Column="17" TopLine="55"/>301 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 302 <Caret Line="187" Column="1" TopLine="168"/> 236 303 </Position6> 237 304 <Position7> 238 <Filename Value=" UMainForm.pas"/>239 <Caret Line="1 64" Column="1" TopLine="140"/>305 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 306 <Caret Line="189" Column="1" TopLine="168"/> 240 307 </Position7> 241 308 <Position8> 242 <Filename Value=" UFastBitmap.pas"/>243 <Caret Line=" 13" Column="7" TopLine="4"/>309 <Filename Value="bgrabitmap/bgradefaultbitmap.pas"/> 310 <Caret Line="809" Column="1" TopLine="796"/> 244 311 </Position8> 245 312 <Position9> 246 <Filename Value=" UMainForm.pas"/>247 <Caret Line=" 90" Column="23" TopLine="78"/>313 <Filename Value="bgrabitmap/bgradefaultbitmap.pas"/> 314 <Caret Line="810" Column="1" TopLine="796"/> 248 315 </Position9> 249 316 <Position10> 250 <Filename Value=" UMainForm.pas"/>251 <Caret Line=" 91" Column="17" TopLine="78"/>317 <Filename Value="bgrabitmap/bgrawinbitmap.pas"/> 318 <Caret Line="190" Column="1" TopLine="169"/> 252 319 </Position10> 253 320 <Position11> 254 <Filename Value=" UMainForm.pas"/>255 <Caret Line=" 48" Column="1" TopLine="33"/>321 <Filename Value="bgrabitmap/bgradefaultbitmap.pas"/> 322 <Caret Line="503" Column="1" TopLine="490"/> 256 323 </Position11> 257 324 <Position12> 258 <Filename Value="U MainForm.pas"/>259 <Caret Line=" 96" Column="1" TopLine="74"/>325 <Filename Value="UDrawMethod.pas"/> 326 <Caret Line="102" Column="1" TopLine="96"/> 260 327 </Position12> 261 328 <Position13> 262 <Filename Value="U MainForm.pas"/>263 <Caret Line="1 61" Column="7" TopLine="139"/>329 <Filename Value="UDrawMethod.pas"/> 330 <Caret Line="133" Column="25" TopLine="111"/> 264 331 </Position13> 265 332 <Position14> 266 <Filename Value="U MainForm.pas"/>267 <Caret Line="1 46" Column="7" TopLine="101"/>333 <Filename Value="UDrawMethod.pas"/> 334 <Caret Line="134" Column="16" TopLine="111"/> 268 335 </Position14> 269 336 <Position15> 270 337 <Filename Value="UMainForm.pas"/> 271 <Caret Line=" 84" Column="3" TopLine="82"/>338 <Caret Line="78" Column="50" TopLine="67"/> 272 339 </Position15> 273 340 <Position16> 274 <Filename Value="U MainForm.pas"/>275 <Caret Line="8 8" Column="1" TopLine="82"/>341 <Filename Value="UDrawMethod.pas"/> 342 <Caret Line="8" Column="32" TopLine="3"/> 276 343 </Position16> 277 344 <Position17> 278 345 <Filename Value="UMainForm.pas"/> 279 <Caret Line=" 156" Column="35" TopLine="26"/>346 <Caret Line="8" Column="20" TopLine="1"/> 280 347 </Position17> 281 348 <Position18> 282 349 <Filename Value="UMainForm.pas"/> 283 <Caret Line=" 88" Column="1" TopLine="75"/>350 <Caret Line="33" Column="19" TopLine="12"/> 284 351 </Position18> 285 352 <Position19> 286 <Filename Value="U MainForm.pas"/>287 <Caret Line="8 9" Column="1" TopLine="75"/>353 <Filename Value="UDrawMethod.pas"/> 354 <Caret Line="8" Column="42" TopLine="1"/> 288 355 </Position19> 289 356 <Position20> 290 <Filename Value="U MainForm.pas"/>291 <Caret Line=" 91" Column="89" TopLine="69"/>357 <Filename Value="UDrawMethod.pas"/> 358 <Caret Line="29" Column="39" TopLine="14"/> 292 359 </Position20> 293 360 <Position21> 294 361 <Filename Value="UDrawMethod.pas"/> 295 <Caret Line="1 94" Column="40" TopLine="182"/>362 <Caret Line="138" Column="5" TopLine="120"/> 296 363 </Position21> 297 364 <Position22> 298 365 <Filename Value="UDrawMethod.pas"/> 299 <Caret Line="17 0" Column="1" TopLine="157"/>366 <Caret Line="173" Column="23" TopLine="157"/> 300 367 </Position22> 301 368 <Position23> 302 369 <Filename Value="UDrawMethod.pas"/> 303 <Caret Line="1 93" Column="3" TopLine="189"/>370 <Caret Line="158" Column="12" TopLine="155"/> 304 371 </Position23> 305 372 <Position24> 306 373 <Filename Value="UDrawMethod.pas"/> 307 <Caret Line=" 71" Column="34" TopLine="60"/>374 <Caret Line="28" Column="34" TopLine="14"/> 308 375 </Position24> 309 376 <Position25> 310 377 <Filename Value="UDrawMethod.pas"/> 311 <Caret Line=" 21" Column="17" TopLine="8"/>378 <Caret Line="177" Column="48" TopLine="155"/> 312 379 </Position25> 313 380 <Position26> 314 381 <Filename Value="UDrawMethod.pas"/> 315 <Caret Line=" 248" Column="3" TopLine="245"/>382 <Caret Line="316" Column="26" TopLine="305"/> 316 383 </Position26> 317 384 <Position27> 318 385 <Filename Value="UDrawMethod.pas"/> 319 <Caret Line=" 195" Column="1" TopLine="182"/>386 <Caret Line="329" Column="3" TopLine="327"/> 320 387 </Position27> 321 388 <Position28> 322 389 <Filename Value="UDrawMethod.pas"/> 323 <Caret Line="1 96" Column="1" TopLine="182"/>390 <Caret Line="178" Column="29" TopLine="164"/> 324 391 </Position28> 325 392 <Position29> 326 <Filename Value="U MainForm.pas"/>327 <Caret Line=" 91" Column="89" TopLine="69"/>393 <Filename Value="UDrawMethod.pas"/> 394 <Caret Line="179" Column="22" TopLine="164"/> 328 395 </Position29> 329 <Position30>330 <Filename Value="UMainForm.pas"/>331 <Caret Line="119" Column="1" TopLine="101"/>332 </Position30>333 396 </JumpHistory> 334 397 </ProjectOptions> … … 340 403 <SearchPaths> 341 404 <IncludeFiles Value="$(ProjOutDir)"/> 405 <OtherUnitFiles Value="BGRABitmap"/> 342 406 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 343 407 </SearchPaths> … … 350 414 </Linking> 351 415 <Other> 416 <CompilerMessages> 417 <UseMsgFile Value="True"/> 418 </CompilerMessages> 352 419 <CompilerPath Value="$(CompPath)"/> 353 420 </Other> -
GraphicTest/UDrawMethod.pas
r201 r202 6 6 7 7 uses 8 Classes, SysUtils, UPlatform, UFastBitmap, Graphics, 9 LCLType, IntfGraphics, fpImage, GraphType; 8 Classes, SysUtils, StdCtrls, ExtCtrls, UPlatform, UFastBitmap, Graphics, 9 LCLType, IntfGraphics, fpImage, GraphType, BGRABitmap, BGRABitmapTypes, 10 LclIntf; 10 11 11 12 type … … 14 15 15 16 TDrawMethod = class 17 private 18 FBitmap: TBitmap; 19 TempBitmap: TBitmap; 20 FPaintBox: TPaintBox; 21 procedure SetBitmap(const AValue: TBitmap); virtual; 22 procedure SetPaintBox(const AValue: TPaintBox); 16 23 public 17 24 Caption: string; 18 25 Terminated: Boolean; 19 Bitmap: TBitmap;20 26 FrameDuration: TDateTime; 21 27 constructor Create; virtual; 28 destructor Destroy; override; 22 29 procedure DrawFrame(FastBitmap: TFastBitmap); virtual; 23 30 procedure DrawFrameTiming(FastBitmap: TFastBitmap); 24 procedure DrawLoop; 31 property Bitmap: TBitmap read FBitmap write SetBitmap; 32 property PaintBox: TPaintBox read FPaintBox write SetPaintBox; 25 33 end; 26 34 … … 54 62 TLazIntfImageColorsNoCopy = class(TDrawMethod) 55 63 TempIntfImage: TLazIntfImage; 64 procedure SetBitmap(const AValue: TBitmap); override; 56 65 constructor Create; override; 57 66 destructor Destroy; override; … … 73 82 end; 74 83 84 { TBGRABitmapPaintBox } 85 86 TBGRABitmapPaintBox = class(TDrawMethod) 87 BGRABitmap: TBGRABitmap; 88 procedure SetBitmap(const AValue: TBitmap); override; 89 constructor Create; override; 90 destructor Destroy; override; 91 procedure DrawFrame(FastBitmap: TFastBitmap); override; 92 end; 93 75 94 const 76 DrawMethodClasses: array[0.. 5] of TDrawMethodClass = (95 DrawMethodClasses: array[0..6] of TDrawMethodClass = ( 77 96 TCanvasPixels, TCanvasPixelsUpdateLock, TLazIntfImageColorsCopy, 78 TLazIntfImageColorsNoCopy, TBitmapRawImageData, TBitmapRawImageDataPaintBox); 97 TLazIntfImageColorsNoCopy, TBitmapRawImageData, TBitmapRawImageDataPaintBox, 98 TBGRABitmapPaintBox); 79 99 80 100 implementation 81 101 102 { TBGRABitmapPaintBox } 103 104 procedure TBGRABitmapPaintBox.SetBitmap(const AValue: TBitmap); 105 begin 106 inherited; 107 BGRABitmap.SetSize(Bitmap.Width, Bitmap.Height); 108 end; 109 110 constructor TBGRABitmapPaintBox.Create; 111 begin 112 inherited; 113 Caption := 'TBGRABitmap PaintBox'; 114 BGRABitmap := TBGRABitmap.Create(0, 0); 115 end; 116 117 destructor TBGRABitmapPaintBox.Destroy; 118 begin 119 BGRABitmap.Free; 120 inherited Destroy; 121 end; 122 123 procedure TBGRABitmapPaintBox.DrawFrame(FastBitmap: TFastBitmap); 124 var 125 X, Y: Integer; 126 P: PBGRAPixel; 127 begin 128 with FastBitmap do 129 for Y := 0 to Size.Y - 1 do begin 130 P := BGRABitmap.ScanLine[Y]; 131 for X := 0 to Size.X - 1 do begin 132 P^.red := Pixels[X, Y]; 133 P^.green := Pixels[X, Y]; 134 P^.blue := Pixels[X, Y]; 135 P^.alpha := 255; 136 Inc(P); 137 end; 138 end; 139 BGRABitmap.InvalidateBitmap; // changed by direct access 140 //BGRABitmap.Draw(Bitmap.Canvas, 0, 0, False); 141 BGRABitmap.Draw(PaintBox.Canvas, 0, 0, True); 142 end; 143 82 144 { TBitmapRawImageDataPaintBox } 83 145 84 146 constructor TBitmapRawImageDataPaintBox.Create; 85 147 begin 148 inherited; 86 149 Caption := 'TBitmap.RawImage.Data PaintBox'; 87 150 end; … … 95 158 BytePerPixel: Integer; 96 159 hPaint, hBmp: HDC; 160 begin 161 P := TempBitmap.PixelFormat; 162 with FastBitmap do 163 try 164 TempBitmap.BeginUpdate(False); 165 RawImage := TempBitmap.RawImage; 166 PixelPtr := PInteger(RawImage.Data); 167 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; 171 Inc(PByte(PixelPtr), BytePerPixel); 172 end; 173 finally 174 TempBitmap.EndUpdate(False); 175 end; 176 hBmp := TempBitmap.Canvas.Handle; 177 hPaint := PaintBox.Canvas.Handle; 178 PaintBox.Canvas.CopyRect(Rect(0, 0, Bitmap.Width, Bitmap.Height), TempBitmap.Canvas, 179 Rect(0, 0, TempBitmap.Width, TempBitmap.Height)); 180 //BitBlt(hPaint, 0, 0, TempBitmap.Width, TempBitmap.Height, hBmp, 0, 0, srcCopy); 181 end; 182 183 { TBitmapRawImageData } 184 185 constructor TBitmapRawImageData.Create; 186 begin 187 inherited; 188 Caption := 'TBitmap.RawImage.Data'; 189 end; 190 191 procedure TBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap); 192 var 193 Y, X: Integer; 194 PixelPtr: PInteger; 195 P: TPixelFormat; 196 RawImage: TRawImage; 197 BytePerPixel: Integer; 97 198 begin 98 199 P := Bitmap.PixelFormat; … … 111 212 Bitmap.EndUpdate(False); 112 213 end; 113 hBmp := Bitmap.Canvas.Handle;114 //hPaint := PaintBox1.Canvas.Handle;115 //BitBlt(hPaint, 0, 0, Bitmap.Width, Bitmap.Height, hBmp, 0, 0, srcCopy);116 end;117 118 { TBitmapRawImageData }119 120 constructor TBitmapRawImageData.Create;121 begin122 Caption := 'TBitmap.RawImage.Data';123 end;124 125 procedure TBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap);126 var127 Y, X: Integer;128 PixelPtr: PInteger;129 P: TPixelFormat;130 RawImage: TRawImage;131 BytePerPixel: Integer;132 begin133 P := Bitmap.PixelFormat;134 with FastBitmap do135 try136 Bitmap.BeginUpdate(False);137 RawImage := Bitmap.RawImage;138 PixelPtr := PInteger(RawImage.Data);139 BytePerPixel := RawImage.Description.BitsPerPixel div 8;140 for X := 0 to Size.X - 1 do141 for Y := 0 to Size.Y - 1 do begin142 PixelPtr^ := Pixels[X, Y] * $010101;143 Inc(PByte(PixelPtr), BytePerPixel);144 end;145 finally146 Bitmap.EndUpdate(False);147 end;148 214 end; 149 215 150 216 { TLazIntfImageColorsNoCopy } 151 217 218 procedure TLazIntfImageColorsNoCopy.SetBitmap(const AValue: TBitmap); 219 begin 220 inherited SetBitmap(AValue); 221 TempIntfImage.Free; 222 TempIntfImage := Bitmap.CreateIntfImage; 223 end; 224 152 225 constructor TLazIntfImageColorsNoCopy.Create; 153 226 begin 227 inherited; 154 228 Caption := 'TLazIntfImage.Colors no copy'; 155 229 end; … … 166 240 begin 167 241 with FastBitmap do begin 168 if not Assigned(TempIntfImage) then169 TempIntfImage := Bitmap.CreateIntfImage;170 242 for X := 0 to Size.X - 1 do 171 243 for Y := 0 to Size.Y - 1 do … … 179 251 constructor TLazIntfImageColorsCopy.Create; 180 252 begin 253 inherited; 181 254 Caption := 'TLazIntfImage.Colors copy'; 182 255 TempIntfImage := TLazIntfImage.Create(0, 0); … … 207 280 constructor TCanvasPixelsUpdateLock.Create; 208 281 begin 282 inherited; 209 283 Caption := 'TBitmap.Canvas.Pixels Update locking'; 210 284 end; … … 229 303 constructor TCanvasPixels.Create; 230 304 begin 305 inherited; 231 306 Caption := 'TBitmap.Canvas.Pixels'; 232 307 end; … … 245 320 { TDrawMethod } 246 321 322 procedure TDrawMethod.SetBitmap(const AValue: TBitmap); 323 begin 324 if FBitmap = AValue then exit; 325 FBitmap := AValue; 326 TempBitmap.SetSize(FBitmap.Width, FBitmap.Height); 327 end; 328 329 procedure TDrawMethod.SetPaintBox(const AValue: TPaintBox); 330 begin 331 if FPaintBox = AValue then Exit; 332 FPaintBox := AValue; 333 end; 334 247 335 constructor TDrawMethod.Create; 248 336 begin 249 337 TempBitmap := TBitmap.Create; 338 end; 339 340 destructor TDrawMethod.Destroy; 341 begin 342 TempBitmap.Free; 343 inherited Destroy; 250 344 end; 251 345 … … 264 358 end; 265 359 266 procedure TDrawMethod.DrawLoop;267 begin268 end;269 270 360 end. 271 361 -
GraphicTest/UMainForm.lfm
r201 r202 1 1 object MainForm: TMainForm 2 Left = 2 912 Left = 214 3 3 Height = 452 4 Top = 1 274 Top = 106 5 5 Width = 731 6 6 Caption = 'Graphic test' … … 55 55 end 56 56 object Label1: TLabel 57 Left = 1157 Left = 9 58 58 Height = 14 59 59 Top = 95 … … 81 81 end 82 82 object Label3: TLabel 83 Left = 1183 Left = 9 84 84 Height = 14 85 85 Top = 112 … … 131 131 Height = 21 132 132 Top = 64 133 Width = 2 33133 Width = 297 134 134 ItemHeight = 13 135 Items.Strings = (136 'TBitmap.Canvas.Pixels'137 'TBitmap.Canvas.Pixels Update lock'138 'TLazIntfImage copy from'139 'TLazIntfImage create new'140 'TBitmap.RawData on TImage'141 'TBitmap.RawData on TPaintBox'142 )143 135 Style = csDropDownList 144 136 TabOrder = 5 -
GraphicTest/UMainForm.pas
r201 r202 44 44 private 45 45 public 46 DrawMethod : TDrawMethod;46 DrawMethods: TObjectList; // TObjectList<TDrawMethod> 47 47 Bitmap: TBitmap; 48 48 Scenes: TObjectList; // TObjectList<TFastBitmap> … … 62 62 var 63 63 NewScene: TFastBitmap; 64 NewDrawMethod: TDrawMethod; 64 65 I: Integer; 65 66 begin … … 77 78 Image1.Picture.Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y); 78 79 Bitmap.SetSize(TFastBitmap(Scenes[0]).Size.X, TFastBitmap(Scenes[0]).Size.Y); 80 81 DrawMethods := TObjectList.Create; 82 ComboBox1.Clear; 83 for I := 0 to High(DrawMethodClasses) do begin 84 NewDrawMethod := DrawMethodClasses[I].Create; 85 NewDrawMethod.Bitmap := Image1.Picture.Bitmap; 86 NewDrawMethod.PaintBox := PaintBox1; 87 DrawMethods.Add(NewDrawMethod); 88 ComboBox1.Items.Add(NewDrawMethod.Caption); 89 end; 79 90 ComboBox1.ItemIndex := 0; 80 91 end; … … 85 96 ButtonStart.Enabled := False; 86 97 Timer1.Enabled := True; 87 DrawMethod.Free; 88 if ComboBox1.ItemIndex >= 0 then begin 89 DrawMethod := DrawMethodClasses[ComboBox1.ItemIndex].Create; 90 DrawMethod.Bitmap := Image1.Picture.Bitmap; 91 DrawMethod.Bitmap.SetSize(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height); 98 if ComboBox1.ItemIndex >= 0 then 99 with TDrawMethod(DrawMethods[ComboBox1.ItemIndex]) do begin 92 100 repeat 93 Draw Method.DrawFrameTiming(TFastBitmap(Scenes[SceneIndex]));101 DrawFrameTiming(TFastBitmap(Scenes[SceneIndex])); 94 102 SceneIndex := (SceneIndex + 1) mod Scenes.Count; 95 103 Application.ProcessMessages; … … 108 116 BeginUpdate; 109 117 Clear; 110 for I := 0 to High(DrawMethodClasses) do begin 111 DrawMethod.Free; 112 DrawMethod := DrawMethodClasses[I].Create; 113 DrawMethod.Bitmap := Image1.Picture.Bitmap; 114 DrawMethod.Bitmap.SetSize(Image1.Picture.Bitmap.Width, Image1.Picture.Bitmap.Height); 115 DrawMethod.DrawFrameTiming(TFastBitmap(Scenes[0])); 118 for I := 0 to DrawMethods.Count - 1 do 119 with TDrawMethod(DrawMethods[I]) do begin 120 DrawFrameTiming(TFastBitmap(Scenes[0])); 121 DrawFrameTiming(TFastBitmap(Scenes[0])); 116 122 NewItem := Add; 117 NewItem.Caption := DrawMethod.Caption;118 NewItem.SubItems.Add(FloatToStr(RoundTo( DrawMethod.FrameDuration / OneMillisecond, -3)));119 NewItem.SubItems.Add(FloatToStr(RoundTo(1 / ( DrawMethod.FrameDuration / OneSecond), -3)));123 NewItem.Caption := Caption; 124 NewItem.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3))); 125 NewItem.SubItems.Add(FloatToStr(RoundTo(1 / (FrameDuration / OneSecond), -3))); 120 126 end; 121 127 finally … … 137 143 procedure TMainForm.FormDestroy(Sender: TObject); 138 144 begin 145 DrawMethods.Free; 139 146 Scenes.Free; 140 147 Bitmap.Free; … … 143 150 procedure TMainForm.Timer1Timer(Sender: TObject); 144 151 begin 145 if Assigned(DrawMethod) then begin 146 if (DrawMethod.FrameDuration > 0) then 147 Label2.Caption := FloatToStr(RoundTo(1 / (DrawMethod.FrameDuration / OneSecond), -3)) 152 if (ComboBox1.ItemIndex >= 0) then 153 with TDrawMethod(DrawMethods[ComboBox1.ItemIndex]) do begin 154 if (FrameDuration > 0) then 155 Label2.Caption := FloatToStr(RoundTo(1 / (FrameDuration / OneSecond), -3)) 148 156 else Label2.Caption := '0'; 149 Label4.Caption := FloatToStr(RoundTo( DrawMethod.FrameDuration / OneMillisecond, -3)) + ' ms';157 Label4.Caption := FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3)) + ' ms'; 150 158 end; 151 159 end;
Note:
See TracChangeset
for help on using the changeset viewer.