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/img/masktest/masktest.pas | |
parent | 10b66d63a8763ed62019d7789635b84372f4e463 (diff) | |
download | fpGUI-6c6aa999c078adae842ec37b44a7deafb27b7134.tar.xz |
Updated the img/masktest example to compile with latest GFX changes.
Diffstat (limited to 'examples/img/masktest/masktest.pas')
-rw-r--r-- | examples/img/masktest/masktest.pas | 89 |
1 files changed, 44 insertions, 45 deletions
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. |