diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-07-16 10:08:28 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-07-16 10:08:28 +0000 |
commit | 18a3ef60ba3c2ef8bd3f842c5b7e70cdf5a9c5c3 (patch) | |
tree | 8cb70a3a29cf3541cea58ba923e3c6ebb10cdcde /Game/Code/MacOSX/Wrapper/Graphics.pas | |
parent | 4dd9427bd27321e5ac8e9bff9a677f527294ac97 (diff) | |
download | usdx-18a3ef60ba3c2ef8bd3f842c5b7e70cdf5a9c5c3.tar.gz usdx-18a3ef60ba3c2ef8bd3f842c5b7e70cdf5a9c5c3.tar.xz usdx-18a3ef60ba3c2ef8bd3f842c5b7e70cdf5a9c5c3.zip |
removed outdated files
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1202 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/MacOSX/Wrapper/Graphics.pas | 190 |
1 files changed, 0 insertions, 190 deletions
diff --git a/Game/Code/MacOSX/Wrapper/Graphics.pas b/Game/Code/MacOSX/Wrapper/Graphics.pas deleted file mode 100644 index 39462607..00000000 --- a/Game/Code/MacOSX/Wrapper/Graphics.pas +++ /dev/null @@ -1,190 +0,0 @@ -unit Graphics; - -{$I switches.inc} - -interface - -uses - Classes, SysUtils, Windows, FreeBitmap, FreeImage; - -type - TPixelFormat = (pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom); - TColor = -$7FFFFFFF-1..$7FFFFFFF; - - TCanvas = class - private - FImage : TFreeBitmap; - function GetPixel(x, y: Integer): TColor; - procedure SetPixel(x, y: Integer; const Value: TColor); - public - Constructor Create(const bmp : TFreeBitmap); - property Pixels[x,y : Integer] : TColor read GetPixel write SetPixel; - end; - - TBitmap = class - private - FCanvas : TCanvas; - function GetHeight: Integer; - function GetWidth: Integer; - procedure SetHeight(const Value: Integer); - procedure SetWidth(const Value: Integer); - function GetPixelFormat: TPixelFormat; - procedure SetPixelFormat(const Value: TPixelFormat); - function GetScanLine(Line: Integer): Pointer; - protected - FImage : TFreeBitmap; - public - Constructor Create; - Destructor Destroy; override; - Procedure LoadFromStream(const str : TStream); - Procedure LoadFromFile(const f : String); - Procedure SaveToFile(const f : String); virtual; - Procedure Assign(const src : TBitmap); - property Width : Integer read GetWidth write SetWidth; - property Height : Integer read GetHeight write SetHeight; - property PixelFormat : TPixelFormat read GetPixelFormat write SetPixelFormat; - property ScanLine[Line : Integer] : Pointer read GetScanLine; - property Canvas : TCanvas read FCanvas; - end; - -implementation - -{ TBitmap } - -type - TRealRGB = packed record - rgbRed: Byte; - rgbGreen: Byte; - rgbBlue: Byte; - rgbReserved: Byte; - end; - -procedure TBitmap.Assign(const src: TBitmap); -begin - FImage.Assign(src.FImage); - FCanvas.FImage := FImage; -end; - -constructor TBitmap.Create; -begin - FImage := TFreeBitmap.Create( FIF_BMP, 4, 4, 24); - FCanvas := TCanvas.Create(FImage); -end; - -destructor TBitmap.Destroy; -begin - FCanvas.Free; - FImage.Free; - inherited; -end; - -function TBitmap.GetHeight: Integer; -begin - Result := FImage.GetHeight; -end; - -function TBitmap.GetPixelFormat: TPixelFormat; -begin - Result := pf24bit; - - case FImage.GetBitsPerPixel of - 1 : Result := pf1bit; - 4 : Result := pf4bit; - 8 : Result := pf8bit; - 15 : Result := pf15bit; - 16 : Result := pf16bit; - 24 : Result := pf24bit; - 32 : Result := pf32bit; - end; -end; - -function TBitmap.GetScanLine(Line: Integer): Pointer; -begin - Result := FImage.GetScanLine(Height-1-Line); -end; - -function TBitmap.GetWidth: Integer; -begin - Result := FImage.GetWidth; -end; - -procedure TBitmap.LoadFromFile(const f: String); -begin - FreeAndNil(FCanvas); - FreeAndNil(FImage); - FImage := TFreeBitmap.Create; - FImage.Load(f); - FCanvas := TCanvas.Create(FImage); -end; - -procedure TBitmap.LoadFromStream(const str: TStream); -begin - FreeAndNil(FCanvas); - FreeAndNil(FImage); - FImage := TFreeBitmap.Create; - FImage.LoadFromStream(str); - FCanvas := TCanvas.Create(FImage); -end; - -procedure TBitmap.SaveToFile(const f: String); -begin - FImage.Save(f); -end; - -procedure TBitmap.SetHeight(const Value: Integer); -begin - if Value <> Height then begin - FImage.Rescale( Width, Value, FILTER_BILINEAR); - end; -end; - -procedure TBitmap.SetPixelFormat(const Value: TPixelFormat); -begin - if Value <> PixelFormat then begin - case Value of - pf4bit : FImage.ConvertTo4Bits; - pf8bit : FImage.ConvertTo8Bits; - pf15bit : FImage.ConvertTo16Bits555; - pf16bit : FImage.ConvertTo16Bits565; - pf24bit : FImage.ConvertTo24Bits; - pf32bit : FImage.ConvertTo32Bits; - end; - end; -end; - -procedure TBitmap.SetWidth(const Value: Integer); -begin - if Value <> Width then begin - FImage.Rescale( Value, Height, FILTER_BILINEAR); - end; -end; - -{ TCanvas } - -constructor TCanvas.Create(const bmp: TFreeBitmap); -begin - FImage := bmp; -end; - -function TCanvas.GetPixel(x, y: Integer): TColor; -var - pix : TRGBQuad; -begin - FImage.GetPixelColor( x, FImage.GetHeight-1-y, @pix); - Result := TColor(pix); -end; - -procedure TCanvas.SetPixel(x, y: Integer; const Value: TColor); -var - pixRGB : TRealRGB; - pixBGR : TRGBQuad; -begin - Move( Value, pixRGB, SizeOf(pixRGB)); - pixBGR.rgbRed := pixRGB.rgbRed; - pixBGR.rgbGreen := pixRGB.rgbGreen; - pixBGR.rgbBlue := pixRGB.rgbBlue; - pixBGR.rgbReserved := pixRGB.rgbReserved; - FImage.SetPixelColor( x, FImage.GetHeight-1-y, @pixBGR); -end; - -end. |