Changeset 212 for GraphicTest/UFastBitmap.pas
- Timestamp:
- Mar 20, 2011, 7:18:27 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/UFastBitmap.pas
r206 r212 33 33 end; 34 34 35 { TFastBitmap3 } 36 37 TFastBitmap3 = class 38 private 39 FPixelsData: PByte; 40 FSize: TPoint; 41 procedure SetSize(const AValue: TPoint); 42 public 43 constructor Create; 44 destructor Destroy; override; 45 procedure RandomImage; 46 property Size: TPoint read FSize write SetSize; 47 function GetPixelAddress(X, Y: Integer): PFastBitmapPixel; inline; 48 function GetPixelSize: Integer; inline; 49 end; 50 35 51 TFastBitmap2 = class 36 52 private … … 64 80 end; 65 81 82 { TFastBitmap3 } 83 84 procedure TFastBitmap3.SetSize(const AValue: TPoint); 85 begin 86 if (FSize.X = AValue.X) and (FSize.Y = AValue.X) then Exit; 87 FSize := AValue; 88 FPixelsData := ReAllocMem(FPixelsData, FSize.X * FSize.Y * SizeOf(TFastBitmapPixel)); 89 end; 90 91 constructor TFastBitmap3.Create; 92 begin 93 94 end; 95 96 destructor TFastBitmap3.Destroy; 97 begin 98 inherited Destroy; 99 end; 100 101 procedure TFastBitmap3.RandomImage; 102 var 103 I, X, Y: Integer; 104 PRow: PFastBitmapPixel; 105 PPixel: PFastBitmapPixel; 106 begin 107 for I := 0 to 2 do begin 108 PRow := GetPixelAddress(I * (Size.X div 3), 0); 109 for Y := 0 to (Size.Y div 2) - 1 do begin 110 PPixel := PRow; 111 for X := 0 to (Size.X div 3) - 1 do begin 112 PPixel^ := 255 shl (I * 8); 113 Inc(PPixel); 114 end; 115 Inc(PRow, Size.X); 116 end; 117 end; 118 119 PRow := GetPixelAddress(0, Size.Y div 2); 120 for Y := (Size.Y div 2) to Size.Y - 1 do begin 121 PPixel := PRow; 122 for X := 0 to Size.X - 1 do begin 123 PPixel^ := Random(256) or (Random(256) shl 16) or (Random(256) shl 8); 124 Inc(PPixel); 125 end; 126 Inc(PRow, Size.X); 127 end; 128 end; 129 130 function TFastBitmap3.GetPixelAddress(X, Y: Integer): PFastBitmapPixel; 131 begin 132 Result := PFastBitmapPixel(FPixelsData) + Y * FSize.X + X; 133 end; 134 135 function TFastBitmap3.GetPixelSize: Integer; 136 begin 137 Result := SizeOf(TFastBitmapPixel); 138 end; 139 66 140 { TFastBitmap2 } 67 141
Note:
See TracChangeset
for help on using the changeset viewer.