From 6c6aa999c078adae842ec37b44a7deafb27b7134 Mon Sep 17 00:00:00 2001 From: graemeg Date: Mon, 28 May 2007 12:53:58 +0000 Subject: Updated the img/masktest example to compile with latest GFX changes. --- examples/img/disp_bmp/disp_bmp.pas | 10 +--- examples/img/disp_bmp/test.bmp | Bin 196662 -> 0 bytes examples/img/disp_bmp/test24.bmp | Bin 0 -> 196662 bytes examples/img/masktest/masktest.lpi | 105 ++++++++++++++++++------------------- examples/img/masktest/masktest.pas | 89 ++++++++++++++++--------------- 5 files changed, 98 insertions(+), 106 deletions(-) delete mode 100644 examples/img/disp_bmp/test.bmp create mode 100644 examples/img/disp_bmp/test24.bmp (limited to 'examples') 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/test.bmp deleted file mode 100644 index bda7377d..00000000 Binary files a/examples/img/disp_bmp/test.bmp and /dev/null differ diff --git a/examples/img/disp_bmp/test24.bmp b/examples/img/disp_bmp/test24.bmp new file mode 100644 index 00000000..bda7377d Binary files /dev/null and b/examples/img/disp_bmp/test24.bmp differ 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 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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. -- cgit v1.2.3-70-g09d2