diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-05-28 12:53:58 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-05-28 12:53:58 +0000 |
commit | 6c6aa999c078adae842ec37b44a7deafb27b7134 (patch) | |
tree | 6c406207a5643baa62fd5a09935e44fcbdc815ed /examples | |
parent | 10b66d63a8763ed62019d7789635b84372f4e463 (diff) | |
download | fpGUI-6c6aa999c078adae842ec37b44a7deafb27b7134.tar.xz |
Updated the img/masktest example to compile with latest GFX changes.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/img/disp_bmp/disp_bmp.pas | 10 | ||||
-rw-r--r-- | examples/img/disp_bmp/test24.bmp (renamed from examples/img/disp_bmp/test.bmp) | bin | 196662 -> 196662 bytes | |||
-rw-r--r-- | examples/img/masktest/masktest.lpi | 105 | ||||
-rw-r--r-- | examples/img/masktest/masktest.pas | 89 |
4 files changed, 98 insertions, 106 deletions
diff --git a/examples/img/disp_bmp/disp_bmp.pas b/examples/img/disp_bmp/disp_bmp.pas index 880340c0..5f581195 100644 --- a/examples/img/disp_bmp/disp_bmp.pas +++ b/examples/img/disp_bmp/disp_bmp.pas @@ -57,11 +57,9 @@ end; procedure TMainForm.Paint(Sender: TObject; const Rect: TRect); begin // debug only -{ Canvas.SetColor(colRed); Canvas.FillRect(Rect); Canvas.SetColor(colYellow); -} // paint image Canvas.DrawImage(Image, Point(0, 0)); end; @@ -77,11 +75,7 @@ begin GFApplication.Initialize; MainForm := TMainForm.Create; - try - MainForm.Show; - GFApplication.Run; - finally - MainForm.Free; - end; + MainForm.Show; + GFApplication.Run; end. diff --git a/examples/img/disp_bmp/test.bmp b/examples/img/disp_bmp/test24.bmp Binary files differindex bda7377d..bda7377d 100644 --- a/examples/img/disp_bmp/test.bmp +++ b/examples/img/disp_bmp/test24.bmp diff --git a/examples/img/masktest/masktest.lpi b/examples/img/masktest/masktest.lpi index 6c574c2d..dda2a998 100644 --- a/examples/img/masktest/masktest.lpi +++ b/examples/img/masktest/masktest.lpi @@ -1,53 +1,52 @@ -<?xml version="1.0"?>
-<CONFIG>
- <ProjectOptions>
- <PathDelim Value="\"/>
- <Version Value="5"/>
- <General>
- <SessionStorage Value="InProjectDir"/>
- <MainUnit Value="0"/>
- <IconPath Value="./"/>
- <TargetFileExt Value=".exe"/>
- </General>
- <VersionInfo>
- <ProjectVersion Value=""/>
- </VersionInfo>
- <PublishOptions>
- <Version Value="2"/>
- <IgnoreBinaries Value="False"/>
- <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
- <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
- </PublishOptions>
- <RunParams>
- <local>
- <FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
- </local>
- </RunParams>
- <RequiredPackages Count="2">
- <Item1>
- <PackageName Value="fpimgpackage"/>
- </Item1>
- <Item2>
- <PackageName Value="fpGFXPackage"/>
- </Item2>
- </RequiredPackages>
- <Units Count="1">
- <Unit0>
- <Filename Value="masktest.pas"/>
- <IsPartOfProject Value="True"/>
- <UnitName Value="MaskTest"/>
- </Unit0>
- </Units>
- </ProjectOptions>
- <CompilerOptions>
- <Version Value="5"/>
- <PathDelim Value="\"/>
- <CodeGeneration>
- <Generate Value="Faster"/>
- </CodeGeneration>
- <Other>
- <CompilerPath Value="$(CompPath)"/>
- </Other>
- </CompilerOptions>
-</CONFIG>
+<?xml version="1.0"?> +<CONFIG> + <ProjectOptions> + <PathDelim Value="/"/> + <Version Value="5"/> + <General> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <IconPath Value="./"/> + <TargetFileExt Value=".exe"/> + </General> + <VersionInfo> + <ProjectVersion Value=""/> + </VersionInfo> + <PublishOptions> + <Version Value="2"/> + <IgnoreBinaries Value="False"/> + <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> + <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> + </local> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="fpimgpackage"/> + </Item1> + <Item2> + <PackageName Value="fpGFXPackage"/> + </Item2> + </RequiredPackages> + <Units Count="1"> + <Unit0> + <Filename Value="masktest.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="MaskTest"/> + </Unit0> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="5"/> + <CodeGeneration> + <Generate Value="Faster"/> + </CodeGeneration> + <Other> + <CompilerPath Value="$(CompPath)"/> + </Other> + </CompilerOptions> +</CONFIG> diff --git a/examples/img/masktest/masktest.pas b/examples/img/masktest/masktest.pas index b469dbd5..d9db3e6a 100644 --- a/examples/img/masktest/masktest.pas +++ b/examples/img/masktest/masktest.pas @@ -1,72 +1,71 @@ { - $Id: masktest.pp,v 1.3 2001/02/14 23:08:59 sg Exp $ - - fpImg - Free Pascal Imaging Library - Copyright (C) 2000 - 2001 by - Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org + fpGUI - Free Pascal GUI Library Example: Display BMP file with monochrome mask - See the file COPYING, included in this distribution, - for details about the copyright. + Copyright (C) 2000 - 2007 See the file AUTHORS.txt, included in this + distribution, for details of the copyright. + + See the file COPYING.modifiedLGPL, included in this distribution, + for details about redistributing fpGUI. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. } - program MaskTest; -uses Classes, GFXBase, fpGFX, fpImg, BMPReader; +{$ifdef fpc} + {$mode objfpc}{$H+} +{$endif} + +uses + Classes, GFXBase, fpGFX, fpImg, BMPReader; type - TMainWindow = class - procedure Paint(Sender: TObject; const ARect: TRect); + TMainWindow = class(TFWindow) private - Window: TFWindow; Image2, Image4, Image8, Image24, Mask: TFBitmap; Image2Canvas, Image4Canvas, Image8Canvas, Image24Canvas, MaskCanvas: TFCanvas; + protected + procedure Paint(Sender: TObject; const ARect: TRect); public - constructor Create; - destructor Destroy; override; + constructor Create; overload; + destructor Destroy; override; end; constructor TMainWindow.Create; begin - inherited Create; + inherited Create(nil, [woWindow]); // Load and prepare the images Image2 := CreateImageFromFile(GFScreen, TBMPReader, 'image2.bmp'); - Image2Canvas := TFBitmap.Create(Image2.Width, Image2.Height); + Image2Canvas := TFCanvas(GFScreen.CreateBitmapCanvas(Image2.Width, Image2.Height)); Image2Canvas.DrawImage(Image2, Point(0, 0)); Image4 := CreateImageFromFile(GFScreen, TBMPReader, 'image4.bmp'); - Image4Canvas := - GFScreen.CreateBitmap(Image4.Width, Image4.Height); + Image4Canvas := TFCanvas(GFScreen.CreateBitmapCanvas(Image4.Width, Image4.Height)); Image4Canvas.DrawImage(Image4, Point(0, 0)); Image8 := CreateImageFromFile(GFScreen, TBMPReader, 'image8.bmp'); - Image8Canvas := - Display.DefaultScreen.CreateBitmap(Image8.Width, Image8.Height); + Image8Canvas := TFCanvas(GFScreen.CreateBitmapCanvas(Image8.Width, Image8.Height)); Image8Canvas.DrawImage(Image8, Point(0, 0)); Image24 := CreateImageFromFile(GFScreen, TBMPReader, 'image24.bmp'); - Image24Canvas := - Display.DefaultScreen.CreateBitmap(Image24.Width, Image24.Height); + Image24Canvas := TFCanvas(GFScreen.CreateBitmapCanvas(Image24.Width, Image24.Height)); Image24Canvas.DrawImage(Image24, Point(0, 0)); // Load and prepare the image mask Mask := CreateImageFromFile(GFScreen, TBMPReader, 'mask.bmp'); - MaskCanvas := Display.DefaultScreen.CreateMonoBitmap(Mask.Width, Mask.Height); + MaskCanvas := TFCanvas(GFScreen.CreateMonoBitmapCanvas(Mask.Width, Mask.Height)); +// MaskCanvas := Display.DefaultScreen.CreateMonoBitmap(Mask.Width, Mask.Height); MaskCanvas.DrawImage(Mask, Point(0, 0)); - Window := ADisplay.DefaultScreen.CreateWindow; - Window.Title := 'fpImg Blitting Mask Test'; - Window.OnPaint := @Paint; - Window.SetClientSize(Size(Image2.Width * 2 + 64, Image2.Height * 2 + 64)); - Window.Show; + Title := 'fpImg Blitting Mask Test'; + OnPaint := @Paint; + SetClientSize(Size(Image2.Width * 2 + 64, Image2.Height * 2 + 64)); end; destructor TMainWindow.Destroy; @@ -97,27 +96,28 @@ begin r.Right := ARect.Right; for i := ARect.Top to ARect.Bottom - 1 do begin - Color.Blue := $ffff - (i * $ffff) div Window.Height; + Color.Blue := $ffff - (i * $ffff) div Height; Color.Red := Color.Blue shr 1; - Window.Canvas.SetColor(Color); + Canvas.SetColor(Color); r.Top := i; r.Bottom := i + 1; - Window.Canvas.FillRect(r); + Canvas.FillRect(r); end; - x1 := Window.ClientWidth div 4 - Image2.Width div 2; - y1 := Window.ClientHeight div 4 - Image2.Height div 2; - x2 := x1 + Window.ClientWidth div 2; - y2 := y1 + Window.ClientHeight div 2; - - Window.Canvas.MaskedCopy(Image2Canvas, MaskCanvas, Point(x1, y1)); - Window.Canvas.TextOut(Point(x1, y1 + Image2.Height), 'monochrome'); - Window.Canvas.MaskedCopy(Image4Canvas, MaskCanvas, Point(x2, y1)); - Window.Canvas.TextOut(Point(x2, y1 + Image2.Height), '4bpp palettized'); - Window.Canvas.MaskedCopy(Image8Canvas, MaskCanvas, Point(x1, y2)); - Window.Canvas.TextOut(Point(x1, y2 + Image2.Height), '8bpp palettized'); - Window.Canvas.MaskedCopy(Image24Canvas, MaskCanvas, Point(x2, y2)); - Window.Canvas.TextOut(Point(x2, y2 + Image2.Height), '24bpp true color'); + x1 := ClientWidth div 4 - Image2.Width div 2; + y1 := ClientHeight div 4 - Image2.Height div 2; + x2 := x1 + ClientWidth div 2; + y2 := y1 + ClientHeight div 2; + + Canvas.SetColor(colWhite); + Canvas.MaskedCopy(Image2Canvas, MaskCanvas, Point(x1, y1)); + Canvas.TextOut(Point(x1, y1 + Image2.Height), 'monochrome'); + Canvas.MaskedCopy(Image4Canvas, MaskCanvas, Point(x2, y1)); + Canvas.TextOut(Point(x2, y1 + Image2.Height), '4bpp palettized'); + Canvas.MaskedCopy(Image8Canvas, MaskCanvas, Point(x1, y2)); + Canvas.TextOut(Point(x1, y2 + Image2.Height), '8bpp palettized'); + Canvas.MaskedCopy(Image24Canvas, MaskCanvas, Point(x2, y2)); + Canvas.TextOut(Point(x2, y2 + Image2.Height), '24bpp true color'); end; var @@ -125,7 +125,6 @@ var begin GFApplication.Initialize; MainWindow := TMainWindow.Create; - GFApplication.AddWindow(MainWindow); MainWindow.Show; GFApplication.Run; end. |