Changeset 206 for GraphicTest/UDrawMethod.pas
- Timestamp:
- Mar 18, 2011, 9:34:42 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/UDrawMethod.pas
r203 r206 11 11 12 12 type 13 TPaintObject = (poImage, poPaintBox, poOpenGL); 13 14 14 15 { TDrawMethod } … … 25 26 Terminated: Boolean; 26 27 FrameDuration: TDateTime; 28 PaintObject: TPaintObject; 27 29 constructor Create; virtual; 28 30 destructor Destroy; override; … … 113 115 Caption := 'TBGRABitmap PaintBox'; 114 116 BGRABitmap := TBGRABitmap.Create(0, 0); 117 PaintObject := poPaintBox; 115 118 end; 116 119 … … 124 127 var 125 128 X, Y: Integer; 126 P: P BGRAPixel;129 P: PInteger; 127 130 begin 128 131 with FastBitmap do 129 132 for Y := 0 to Size.Y - 1 do begin 130 P := BGRABitmap.ScanLine[Y];133 P := PInteger(BGRABitmap.ScanLine[Y]); 131 134 for X := 0 to Size.X - 1 do begin 132 P^.red := Pixels[X, Y]; 135 P^ := NoSwapBRComponent(Pixels[X, Y]); 136 (*P^.red := Pixels[X, Y]; 133 137 P^.green := Pixels[X, Y]; 134 138 P^.blue := Pixels[X, Y]; 135 P^.alpha := 255; 139 P^.alpha := 255; *) 136 140 Inc(P); 137 141 end; 138 142 end; 139 BGRABitmap.InvalidateBitmap; // changed by direct access140 //BGRABitmap.Draw(Bitmap.Canvas, 0, 0, False);143 //BGRABitmap.InvalidateBitmap; // changed by direct access 144 //BGRABitmap.Draw(Bitmap.Canvas, 0, 0, True); 141 145 BGRABitmap.Draw(PaintBox.Canvas, 0, 0, True); 146 // Bitmap.RawImage.Ass 142 147 end; 143 148 … … 148 153 inherited; 149 154 Caption := 'TBitmap.RawImage.Data PaintBox'; 155 PaintObject := poPaintBox; 150 156 end; 151 157 … … 154 160 Y, X: Integer; 155 161 PixelPtr: PInteger; 162 RowPtr: PInteger; 156 163 P: TPixelFormat; 157 164 RawImage: TRawImage; 158 165 BytePerPixel: Integer; 166 BytePerRow: Integer; 159 167 hPaint, hBmp: HDC; 160 168 begin … … 164 172 TempBitmap.BeginUpdate(False); 165 173 RawImage := TempBitmap.RawImage; 166 PixelPtr := PInteger(RawImage.Data);174 RowPtr := PInteger(RawImage.Data); 167 175 BytePerPixel := RawImage.Description.BitsPerPixel div 8; 168 for X := 0 to Size.X - 1 do 169 for Y := 0 to Size.Y - 1 do begin 170 PixelPtr^ := Pixels[X, Y] * $010101; 176 BytePerRow := RawImage.Description.BytesPerLine; 177 for Y := 0 to Size.Y - 1 do begin 178 PixelPtr := RowPtr; 179 for X := 0 to Size.X - 1 do begin 180 PixelPtr^ := Pixels[X, Y]; 171 181 Inc(PByte(PixelPtr), BytePerPixel); 172 182 end; 183 Inc(PByte(RowPtr), BytePerRow); 184 end; 173 185 finally 174 186 TempBitmap.EndUpdate(False); … … 190 202 191 203 procedure TBitmapRawImageData.DrawFrame(FastBitmap: TFastBitmap); 204 type 205 TFastBitmapPixelComponents = packed record 206 end; 192 207 var 193 208 Y, X: Integer; … … 210 225 PixelPtr := RowPtr; 211 226 for X := 0 to Size.X - 1 do begin 212 PixelPtr^ := Pixels[X, Y] * $010101;227 PixelPtr^ := Pixels[X, Y]; 213 228 Inc(PByte(PixelPtr), BytePerPixel); 214 229 end; … … 248 263 for X := 0 to Size.X - 1 do 249 264 for Y := 0 to Size.Y - 1 do 250 TempIntfImage.Colors[X, Y] := TColorToFPColor( Pixels[X, Y] * $010101);265 TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y])); 251 266 Bitmap.LoadFromIntfImage(TempIntfImage); 252 267 end; … … 277 292 for X := 0 to Size.X - 1 do 278 293 for Y := 0 to Size.Y - 1 do 279 TempIntfImage.Colors[X, Y] := TColorToFPColor( Pixels[X, Y] * $010101);294 TempIntfImage.Colors[X, Y] := TColorToFPColor(SwapBRComponent(Pixels[X, Y])); 280 295 Bitmap.LoadFromIntfImage(TempIntfImage); 281 296 end; … … 299 314 for X := 0 to Size.X - 1 do 300 315 for Y := 0 to Size.Y - 1 do 301 Bitmap.Canvas.Pixels[X, Y] := Pixels[X, Y] * $010101;316 Bitmap.Canvas.Pixels[X, Y] := SwapBRComponent(Pixels[X, Y]); 302 317 finally 303 318 Bitmap.EndUpdate(False); … … 320 335 for X := 0 to Size.X - 1 do 321 336 for Y := 0 to Size.Y - 1 do 322 Bitmap.Canvas.Pixels[X, Y] := Pixels[X, Y] * $010101;337 Bitmap.Canvas.Pixels[X, Y] := SwapBRComponent(Pixels[X, Y]); 323 338 end; 324 339 end;
Note:
See TracChangeset
for help on using the changeset viewer.