diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-04-30 13:27:50 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2010-04-30 13:27:50 +0200 |
commit | f58d3707004107e3c6b624f5ac1ea0492c72fff5 (patch) | |
tree | f8d1d1aa61ea4ce939b60276c390fae2a78fe3a7 /examples | |
parent | 1e07cb0e062464ecdfac44e5f299bcd7a117fd59 (diff) | |
download | fpGUI-f58d3707004107e3c6b624f5ac1ea0492c72fff5.tar.xz |
Fixed imgtest demo not working under Windows.
* We called the image.UpdateImage to early. We are only supposed
to do it after we populated the imagedata arrow with color values.
* Also reduced the resource usage, by only creating the internal
image once.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gui/imgtest/bitmaptest.lpi | 5 | ||||
-rw-r--r-- | examples/gui/imgtest/bitmaptest.lpr | 29 |
2 files changed, 17 insertions, 17 deletions
diff --git a/examples/gui/imgtest/bitmaptest.lpi b/examples/gui/imgtest/bitmaptest.lpi index af74913a..24ccafc2 100644 --- a/examples/gui/imgtest/bitmaptest.lpi +++ b/examples/gui/imgtest/bitmaptest.lpi @@ -1,15 +1,14 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <PathDelim Value="/"/> - <Version Value="6"/> + <Version Value="7"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> + <LRSInOutputDirectory Value="False"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <IconPath Value="./"/> <TargetFileExt Value=""/> <Title Value="bitmaptest"/> </General> diff --git a/examples/gui/imgtest/bitmaptest.lpr b/examples/gui/imgtest/bitmaptest.lpr index 010ff886..898b7c61 100644 --- a/examples/gui/imgtest/bitmaptest.lpr +++ b/examples/gui/imgtest/bitmaptest.lpr @@ -19,8 +19,7 @@ type TMainForm = class(TfpgForm) private img: TfpgImage; - protected - procedure HandlePaint; override; + procedure FormPaint(Sender: TObject); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -29,22 +28,21 @@ type { TMainForm } -procedure TMainForm.HandlePaint; +procedure TMainForm.FormPaint(Sender: TObject); var i, j: integer; begin - Canvas.BeginDraw; // activate double buffering in time. -// inherited HandlePaint; - img.Free; - img := TfpgImage.Create; - img.AllocateImage(32, 256, 256); - img.UpdateImage; - // populate the bitmap with pretty colors :-) - for j := 0 to 255 do - for i := 0 to 255 do - PLongWord(img.ImageData)[j * 256 + i] := (i shl 16) or (j shl 8); + if not Assigned(img) then // we only need to create the image once + begin + img := TfpgImage.Create; + img.AllocateImage(32, 256, 256); + // populate the bitmap with pretty colors :-) + for j := 0 to 255 do + for i := 0 to 255 do + PLongWord(img.ImageData)[j * 256 + i] := (i shl 16) or (j shl 8); + img.UpdateImage; // now only do we allocate OS resources + end; Canvas.DrawImage(0, 0, img); - Canvas.EndDraw; end; constructor TMainForm.Create(AOwner: TComponent); @@ -52,6 +50,9 @@ begin inherited Create(AOwner); SetPosition(100, 100, 256, 256); WindowTitle := 'fpGUI Bitmap Test'; + WindowPosition := wpOneThirdDown; + Sizeable := False; + OnPaint := @FormPaint; end; destructor TMainForm.Destroy; |