Changeset 447 for GraphicTest/UDrawMethod.pas
- Timestamp:
- Nov 22, 2012, 2:32:10 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/UDrawMethod.pas
r443 r447 7 7 uses 8 8 Classes, SysUtils, ExtCtrls, UPlatform, UFastBitmap, Graphics, Controls, 9 LCLType, IntfGraphics, fpImage, GraphType, BGRABitmap, BGRABitmapTypes,9 LCLType, IntfGraphics, fpImage, GraphType, 10 10 LclIntf{$IFDEF opengl}, GL, GLExt, OpenGLContext{$ENDIF}; 11 11 … … 19 19 private 20 20 FControl: TControl; 21 TempBitmap: TBitmap;22 21 public 23 22 Caption: string; 23 Description: TStringList; 24 24 Terminated: Boolean; 25 25 FrameDuration: TDateTime; 26 26 StepDuration: TDateTime; 27 27 PaintObject: TPaintObject; 28 TempBitmap: TBitmap; 28 29 procedure Init(Parent: TWinControl; Size: TPoint); virtual; 29 30 procedure Done; virtual; … … 52 53 procedure Init(Parent: TWinControl; Size: TPoint); override; 53 54 procedure Done; override; 54 end;55 56 { TDummyMethod }57 58 TDummyMethod = class(TDrawMethod)59 constructor Create; override;60 procedure DrawFrame(FastBitmap: TFastBitmap); override;61 end;62 63 { TCanvasPixels }64 65 TCanvasPixels = class(TDrawMethodImage)66 constructor Create; override;67 procedure DrawFrame(FastBitmap: TFastBitmap); override;68 end;69 70 { TCanvasPixelsUpdateLock }71 72 TCanvasPixelsUpdateLock = class(TDrawMethodImage)73 constructor Create; override;74 procedure DrawFrame(FastBitmap: TFastBitmap); override;75 end;76 77 { TLazIntfImageColorsCopy }78 79 TLazIntfImageColorsCopy = class(TDrawMethodImage)80 TempIntfImage: TLazIntfImage;81 constructor Create; override;82 destructor Destroy; override;83 procedure DrawFrame(FastBitmap: TFastBitmap); override;84 end;85 86 { TLazIntfImageColorsNoCopy }87 88 TLazIntfImageColorsNoCopy = class(TDrawMethodImage)89 TempIntfImage: TLazIntfImage;90 procedure Init(Parent: TWinControl; Size: TPoint); override;91 constructor Create; override;92 destructor Destroy; override;93 procedure DrawFrame(FastBitmap: TFastBitmap); override;94 end;95 96 { TBitmapRawImageData }97 98 TBitmapRawImageData = class(TDrawMethodImage)99 constructor Create; override;100 procedure DrawFrame(FastBitmap: TFastBitmap); override;101 end;102 103 { TBitmapRawImageDataPaintBox }104 105 TBitmapRawImageDataPaintBox = class(TDrawMethodPaintBox)106 constructor Create; override;107 procedure Paint(Sender: TObject); override;108 procedure DrawFrame(FastBitmap: TFastBitmap); override;109 end;110 111 { TBitmapRawImageDataMove }112 113 TBitmapRawImageDataMove = class(TDrawMethodImage)114 constructor Create; override;115 procedure DrawFrame(FastBitmap: TFastBitmap); override;116 end;117 118 { TBGRABitmapPaintBox }119 120 TBGRABitmapPaintBox = class(TDrawMethodPaintBox)121 BGRABitmap: TBGRABitmap;122 procedure Paint(Sender: TObject); override;123 procedure Init(Parent: TWinControl; Size: TPoint); override;124 constructor Create; override;125 destructor Destroy; override;126 procedure DrawFrame(FastBitmap: TFastBitmap); override;127 55 end; 128 56 … … 140 68 end; 141 69 142 { TOpenGLMethod }143 144 TOpenGLMethod = class(TDrawMethodOpenGL)145 constructor Create; override;146 destructor Destroy; override;147 procedure DrawFrame(FastBitmap: TFastBitmap); override;148 end;149 150 { TOpenGLPBOMethod }151 152 TOpenGLPBOMethod = class(TDrawMethodOpenGL)153 pboIds: array[0..1] of GLuint;154 Index, NextIndex: Integer;155 procedure Init(AParent: TWinControl; Size: TPoint); override;156 constructor Create; override;157 destructor Destroy; override;158 procedure DrawFrame(FastBitmap: TFastBitmap); override;159 end;160 70 {$ENDIF} 161 71 162 const163 DrawMethodClasses: array[0..{$IFDEF opengl}10{$ELSE}8{$ENDIF}] of TDrawMethodClass = (164 TCanvasPixels, TCanvasPixelsUpdateLock, TLazIntfImageColorsCopy,165 TLazIntfImageColorsNoCopy, TBitmapRawImageData, TBitmapRawImageDataPaintBox,166 TBitmapRawImageDataMove, TBGRABitmapPaintBox{$IFDEF opengl}, TOpenGLMethod, TOpenGLPBOMethod{$ENDIF}167 ,TDummyMethod);168 72 169 73 implementation … … 212 116 end; 213 117 214 { TDummyMethod }215 216 constructor TDummyMethod.Create;217 begin218 inherited Create;219 Caption := 'Dummy';220 end;221 222 procedure TDummyMethod.DrawFrame(FastBitmap: TFastBitmap);223 begin224 end;225 226 { TBitmapRawImageDataMove }227 228 constructor TBitmapRawImageDataMove.Create;229 begin230 inherited;231 Caption := 'TBitmap.RawImage.Data Move';232 end;233 234 procedure TBitmapRawImageDataMove.DrawFrame(FastBitmap: TFastBitmap);235 var236 Y, X: Integer;237 PixelPtr: PInteger;238 RowPtr: PInteger;239 P: TPixelFormat;240 RawImage: TRawImage;241 BytePerPixel: Integer;242 BytePerRow: Integer;243 begin244 P := Image.Picture.Bitmap.PixelFormat;245 with FastBitmap do246 try247 Image.Picture.Bitmap.BeginUpdate(False);248 RawImage := Image.Picture.Bitmap.RawImage;249 RowPtr := PInteger(RawImage.Data);250 BytePerPixel := RawImage.Description.BitsPerPixel div 8;251 BytePerRow := RawImage.Description.BytesPerLine;252 Move(FastBitmap.PixelsData^, RowPtr^, Size.Y * BytePerRow);253 finally254 Image.Picture.Bitmap.EndUpdate(False);255 end;256 end;257 118 258 119 {$IFDEF opengl} 259 { TOpenGLPBOMethod }260 261 //procedure glGenBuffersARB2 : procedure(n : GLsizei; buffers : PGLuint); extdecl;262 263 procedure TOpenGLPBOMethod.Init(AParent: TWinControl; Size: TPoint);264 var265 DataSize: Integer;266 glExtensions: string;267 begin268 inherited;269 270 OpenGLControl.MakeCurrent;271 DataSize := OpenGLControl.Width * OpenGLControl.Height * SizeOf(Integer);272 // glGenBuffersARB(Length(pboIds), PGLuint(pboIds));273 //if glext_LoadExtension('GL_ARB_pixel_buffer_object') then274 if Load_GL_ARB_vertex_buffer_object then begin275 glGenBuffersARB(2, @pboIds);276 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[0]);277 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, DataSize, Pointer(0), GL_STREAM_READ_ARB);278 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[1]);279 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, DataSize, Pointer(0), GL_STREAM_READ_ARB);280 281 end else raise Exception.Create('GL_ARB_pixel_buffer_object not supported');282 283 glEnable(GL_TEXTURE_2D);284 glBindTexture(GL_TEXTURE_2D, TextureId);285 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);286 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);287 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);288 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);289 glTexImage2D(GL_TEXTURE_2D, 0, 4, OpenGLControl.Width, OpenGLControl.Height,290 0, GL_RGBA, GL_UNSIGNED_BYTE, OpenGLBitmap);291 end;292 293 constructor TOpenGLPBOMethod.Create;294 begin295 inherited Create;296 Caption := 'OpenGL PBO';297 PaintObject := poOpenGL;298 // SetLength(pboIds, 2);299 Index := 0;300 NextIndex := 1;301 end;302 303 destructor TOpenGLPBOMethod.Destroy;304 begin305 inherited Destroy;306 end;307 308 procedure TOpenGLPBOMethod.DrawFrame(FastBitmap: TFastBitmap);309 var310 X, Y: Integer;311 P: PCardinal;312 R: PCardinal;313 Ptr: ^GLubyte;314 TextureShift: TPoint;315 TextureShift2: TPoint;316 const317 GL_CLAMP_TO_EDGE = $812F;318 begin319 // "index" is used to read pixels from framebuffer to a PBO320 // "nextIndex" is used to update pixels in the other PBO321 Index := (Index + 1) mod 2;322 NextIndex := (Index + 1) mod 2;323 324 glLoadIdentity;325 326 glBindTexture(GL_TEXTURE_2D, TextureId);327 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);328 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);329 //glTexImage2D(GL_TEXTURE_2D, 0, 4, OpenGLControl.Width, OpenGLControl.Height,330 // 0, GL_RGBA, GL_UNSIGNED_BYTE, OpenGLBitmap);331 //glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 256,332 //0, GL_RGBA, GL_UNSIGNED_BYTE, OpenGLBitmap);333 334 // bind the texture and PBO335 //glBindTexture(GL_TEXTURE_2D, textureId);336 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboIds[index]);337 338 // copy pixels from PBO to texture object339 // Use offset instead of ponter.340 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, OpenGLControl.Width, OpenGLControl.Height,341 GL_BGRA, GL_UNSIGNED_BYTE, Pointer(0));342 343 344 // bind PBO to update texture source345 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboIds[nextIndex]);346 347 // Note that glMapBufferARB() causes sync issue.348 // If GPU is working with this buffer, glMapBufferARB() will wait(stall)349 // until GPU to finish its job. To avoid waiting (idle), you can call350 // first glBufferDataARB() with NULL pointer before glMapBufferARB().351 // If you do that, the previous data in PBO will be discarded and352 // glMapBufferARB() returns a new allocated pointer immediately353 // even if GPU is still working with the previous data.354 glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, OpenGLControl.Width * OpenGLControl.Height * SizeOf(Integer), Pointer(0), GL_STREAM_DRAW_ARB);355 356 // map the buffer object into client's memory357 ptr := glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY_ARB);358 if Assigned(ptr) then begin359 // update data directly on the mapped buffer360 P := PCardinal(Ptr);361 with FastBitmap do362 for Y := 0 to Size.Y - 2 do begin363 R := P;364 for X := 0 to Size.X - 1 do begin365 R^ := NoSwapBRComponent(Pixels[X, Y]) or $ff000000;366 Inc(R);367 end;368 Inc(P, Size.X);369 end;370 glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);371 end;372 373 // it is good idea to release PBOs with ID 0 after use.374 // Once bound with 0, all pixel operations are back to normal ways.375 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);376 377 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);378 //glRotatef(30.0, 0, 0, 1.0);379 glTranslatef(-OpenGLControl.Width / 2, -OpenGLControl.Height / 2, 0.0);380 glBindTexture(GL_TEXTURE_2D, TextureId);381 382 TextureShift := Point(0, 0);383 TextureShift2 := Point(0, 0);384 glBegin(GL_QUADS);385 glColor3ub(255, 255, 255);386 glTexCoord2f(TextureShift.X, TextureShift.Y);387 glVertex3f(TextureShift2.X, TextureShift2.Y, 0);388 glTexCoord2f(TextureShift.X + OpenGLControl.Width div 2, TextureShift.Y);389 glVertex3f(TextureShift2.X + OpenGLControl.Width, TextureShift2.Y, 0);390 glTexCoord2f(TextureShift.X + OpenGLControl.Width div 2, TextureShift.Y + OpenGLControl.Height div 2);391 glVertex3f(TextureShift2.X + OpenGLControl.Width, TextureShift2.Y + OpenGLControl.Height, 0);392 glTexCoord2f(TextureShift.X, TextureShift.Y + OpenGLControl.Height div 2);393 glVertex3f(TextureShift2.X, TextureShift2.Y + OpenGLControl.Height, 0);394 glEnd();395 396 OpenGLControl.SwapBuffers;397 end;398 399 { TOpenGLMethod }400 401 constructor TOpenGLMethod.Create;402 begin403 inherited Create;404 Caption := 'OpenGL';405 PaintObject := poOpenGL;406 end;407 408 destructor TOpenGLMethod.Destroy;409 begin410 inherited Destroy;411 end;412 413 procedure TOpenGLMethod.DrawFrame(FastBitmap: TFastBitmap);414 var415 X, Y: Integer;416 P: PCardinal;417 R: PCardinal;418 const419 GL_CLAMP_TO_EDGE = $812F;420 begin421 glLoadIdentity;422 glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);423 //glLoadIdentity; { clear the matrix }424 //glTranslatef(0.0, 0.0, -3.0); // -2.5); { viewing transformation }425 426 P := OpenGLBitmap;427 with FastBitmap do428 for Y := 0 to Size.Y - 1 do begin429 R := P;430 for X := 0 to Size.X - 1 do begin431 //R^ := Round($ff * (Y / Size.Y)) or $ff000000;432 R^ := NoSwapBRComponent(Pixels[X, Y]) or $ff000000;433 Inc(R);434 end;435 Inc(P, Size.X);436 end;437 438 //glRotatef(30.0, 0, 0, 1.0);439 glTranslatef(-OpenGLControl.Width div 2, -OpenGLControl.Height div 2, 0.0);440 441 glEnable(GL_TEXTURE_2D);442 glBindTexture(GL_TEXTURE_2D, TextureId);443 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);444 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);445 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);446 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);447 glTexImage2D(GL_TEXTURE_2D, 0, 4, OpenGLControl.Width, OpenGLControl.Height,448 0, GL_RGBA, GL_UNSIGNED_BYTE, OpenGLBitmap);449 //glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 256,450 //0, GL_RGBA, GL_UNSIGNED_BYTE, OpenGLBitmap);451 452 //Define how alpha blending will work and enable alpha blending.453 //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);454 //glEnable(GL_BLEND);455 456 glBegin(GL_QUADS);457 //glBegin(GL_POLYGON);458 glColor3ub(255, 255, 255);459 glTexCoord2f(0, 0);460 glVertex3f(0, 0, 0);461 glTexCoord2f(OpenGLControl.Width div 2, 0);462 glVertex3f(OpenGLControl.Width, 0, 0);463 glTexCoord2f(OpenGLControl.Width div 2, OpenGLControl.Height div 2);464 glVertex3f(OpenGLControl.Width, OpenGLControl.Height, 0);465 glTexCoord2f(0, OpenGLControl.Height div 2);466 glVertex3f(0, OpenGLControl.Height, 0);467 glEnd();468 469 OpenGLControl.SwapBuffers;470 end;471 120 472 121 { TDrawMethodOpenGL } … … 521 170 {$ENDIF} 522 171 523 { TBGRABitmapPaintBox }524 525 procedure TBGRABitmapPaintBox.Paint(Sender: TObject);526 begin527 //BGRABitmap.Draw(Bitmap.Canvas, 0, 0, True);528 BGRABitmap.Draw(PaintBox.Canvas, 0, 0, True);529 end;530 531 procedure TBGRABitmapPaintBox.Init(Parent: TWinControl; Size: TPoint);532 begin533 inherited Init(Parent, Size);534 BGRABitmap.SetSize(PaintBox.Width, PaintBox.Height);535 end;536 537 constructor TBGRABitmapPaintBox.Create;538 begin539 inherited;540 Caption := 'TBGRABitmap PaintBox';541 BGRABitmap := TBGRABitmap.Create(0, 0);542 PaintObject := poPaintBox;543 end;544 545 destructor TBGRABitmapPaintBox.Destroy;546 begin547 BGRABitmap.Free;548 inherited Destroy;549 end;550 551 procedure TBGRABitmapPaintBox.DrawFrame(FastBitmap: TFastBitmap);552 var553 X, Y: Integer;554 P: PCardinal;555 begin556 with FastBitmap do557 for Y := 0 to Size.Y - 1 do begin558 P := PCardinal(BGRABitmap.ScanLine[Y]);559 for X := 0 to Size.X - 1 do begin560 P^ := NoSwapBRComponent(Pixels[X, Y]) or $ff000000;561 //P^ := Pixels[X, Y] or $ff000000;562 (*P^.red := Pixels[X, Y];563 P^.green := Pixels[X, Y];564 P^.blue := Pixels[X, Y];565 P^.alpha := 255; *)566 Inc(P);567 end;568 end;569 BGRABitmap.InvalidateBitmap; // changed by direct access570 PaintBox.Repaint;571 end;572 573 { TBitmapRawImageDataPaintBox }574 575 constructor TBitmapRawImageDataPaintBox.Create;576 begin577 inherited;578 Caption := 'TBitmap.RawImage.Data PaintBox';579 PaintObject := poPaintBox;580 end;581 582 procedure TBitmapRawImageDataPaintBox.Paint(Sender: TObject);583 var584 hPaint, hBmp: HDC;585 begin586 hBmp := TempBitmap.Canvas.Handle;587 hPaint := PaintBox.Canvas.Handle;588 PaintBox.Canvas.CopyRect(Rect(0, 0, PaintBox.Width, PaintBox.Height), TempBitmap.Canvas,589 Rect(0, 0, TempBitmap.Width, TempBitmap.Height));590 // PaintBox.Canvas.Draw(0, 0, TempBitmap);591 //BitBlt(hPaint, 0, 0, TempBitmap.Width, TempBitmap.Height, hBmp, 0, 0, srcCopy);592 end;593 594 procedure TBitmapRawImageDataPaintBox.DrawFrame(FastBitmap: TFastBitmap);595 var596 Y, X: Integer;597 PixelPtr: PCardinal;598 RowPtr: PCardinal;599 P: TPixelFormat;600 RawImage: TRawImage;601 BytePerPixel: Integer;602 BytePerRow: Integer;603 begin604 P := TempBitmap.PixelFormat;605 with FastBitmap do606 try607 TempBitmap.BeginUpdate(False);608 RawImage := TempBitmap.RawImage;609 RowPtr := PCardinal(RawImage.Data);610 BytePerPixel := RawImage.Description.BitsPerPixel div 8;611 BytePerRow := RawImage.Description.BytesPerLine;612 for Y := 0 to Size.Y - 1 do begin613 PixelPtr := RowPtr;614 for X := 0 to Size.X - 1 do begin615 PixelPtr^ := Pixels[X, Y];616 Inc(PByte(PixelPtr), BytePerPixel);617 end;618 Inc(PByte(RowPtr), BytePerRow);619 end;620 finally621 TempBitmap.EndUpdate(False);622 end;623 PaintBox.Repaint;624 end;625 626 { TBitmapRawImageData }627 628 constructor TBitmapRawImageData.Create;629 begin630 inherited;631 Caption := 'TBitmap.RawImage.Data';632 end;633 634 procedure TBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap);635 var636 Y, X: Integer;637 PixelPtr: PCardinal;638 RowPtr: PCardinal;639 P: TPixelFormat;640 RawImage: TRawImage;641 BytePerPixel: Integer;642 BytePerRow: Integer;643 begin644 P := Image.Picture.Bitmap.PixelFormat;645 with FastBitmap do646 try647 Image.Picture.Bitmap.BeginUpdate(False);648 RawImage := Image.Picture.Bitmap.RawImage;649 RowPtr := PCardinal(RawImage.Data);650 BytePerPixel := RawImage.Description.BitsPerPixel div 8;651 BytePerRow := RawImage.Description.BytesPerLine;652 for Y := 0 to Size.Y - 1 do begin653 PixelPtr := RowPtr;654 for X := 0 to Size.X - 1 do begin655 PixelPtr^ := Pixels[X, Y];656 Inc(PByte(PixelPtr), BytePerPixel);657 end;658 Inc(PByte(RowPtr), BytePerRow);659 end;660 finally661 Image.Picture.Bitmap.EndUpdate(False);662 end;663 end;664 665 { TLazIntfImageColorsNoCopy }666 667 procedure TLazIntfImageColorsNoCopy.Init(Parent: TWinControl; Size: TPoint);668 begin669 inherited Init(Parent, Size);670 TempIntfImage.Free;671 TempIntfImage := Image.Picture.Bitmap.CreateIntfImage;672 end;673 674 constructor TLazIntfImageColorsNoCopy.Create;675 begin676 inherited;677 Caption := 'TLazIntfImage.Colors no copy';678 end;679 680 destructor TLazIntfImageColorsNoCopy.Destroy;681 begin682 TempIntfImage.Free;683 inherited Destroy;684 end;685 686 procedure TLazIntfImageColorsNoCopy.DrawFrame(FastBitmap: TFastBitmap);687 var688 Y, X: Integer;689 begin690 with FastBitmap do begin691 for X := 0 to Size.X - 1 do692 for Y := 0 to Size.Y - 1 do693 TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y]));694 Image.Picture.Bitmap.LoadFromIntfImage(TempIntfImage);695 end;696 end;697 698 { TLazIntfImageColorsCopy }699 700 constructor TLazIntfImageColorsCopy.Create;701 begin702 inherited;703 Caption := 'TLazIntfImage.Colors copy';704 TempIntfImage := TLazIntfImage.Create(0, 0);705 end;706 707 destructor TLazIntfImageColorsCopy.Destroy;708 begin709 TempIntfImage.Free;710 inherited Destroy;711 end;712 713 procedure TLazIntfImageColorsCopy.DrawFrame(FastBitmap: TFastBitmap);714 var715 Y, X: Integer;716 begin717 with FastBitmap do begin718 TempIntfImage.LoadFromBitmap(Image.Picture.Bitmap.Handle,719 Image.Picture.Bitmap.MaskHandle);720 for X := 0 to Size.X - 1 do721 for Y := 0 to Size.Y - 1 do722 TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y]));723 Image.Picture.Bitmap.LoadFromIntfImage(TempIntfImage);724 end;725 end;726 727 { TCanvasPixelsUpdateLock }728 729 constructor TCanvasPixelsUpdateLock.Create;730 begin731 inherited;732 Caption := 'TBitmap.Canvas.Pixels Update locking';733 end;734 735 procedure TCanvasPixelsUpdateLock.DrawFrame(FastBitmap: TFastBitmap);736 var737 Y, X: Integer;738 begin739 with FastBitmap do740 try741 Image.Picture.Bitmap.BeginUpdate(True);742 for Y := 0 to Size.Y - 1 do743 for X := 0 to Size.X - 1 do744 Image.Picture.Bitmap.Canvas.Pixels[X, Y] := TColor(SwapBRComponent(Pixels[X, Y]));745 finally746 Image.Picture.Bitmap.EndUpdate(False);747 end;748 end;749 750 { TCanvasPixels }751 752 constructor TCanvasPixels.Create;753 begin754 inherited;755 Caption := 'TBitmap.Canvas.Pixels';756 end;757 758 procedure TCanvasPixels.DrawFrame(FastBitmap: TFastBitmap);759 var760 Y, X: Integer;761 begin762 with FastBitmap do begin763 for Y := 0 to Size.Y - 1 do764 for X := 0 to Size.X - 1 do765 Image.Picture.Bitmap.Canvas.Pixels[X, Y] := TColor(SwapBRComponent(Pixels[X, Y]));766 end;767 end;768 172 769 173 { TDrawMethod } … … 783 187 begin 784 188 TempBitmap := TBitmap.Create; 189 Description := TStringList.Create; 785 190 end; 786 191 787 192 destructor TDrawMethod.Destroy; 788 193 begin 194 FreeAndNil(Description); 789 195 FreeAndNil(TempBitmap); 790 196 inherited Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.