Changeset 25 for branches/gbitmap
- Timestamp:
- Dec 22, 2016, 2:34:33 PM (8 years ago)
- Location:
- branches/gbitmap
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gbitmap/Packages/FastGraphics/ColorFormats/UColorGray1.pas
r24 r25 46 46 procedure Fill(Color: IBColor); override; 47 47 procedure Fill(Func: TGetColorPos); override; 48 procedure Line(P1, P2: TPoint; Color: IBColor); override; 48 49 procedure PaintToCanvas(Canvas: TCanvas); override; 49 50 function GetDataSize: Integer; override; … … 132 133 end; 133 134 135 procedure TBPixmapGray1.Line(P1, P2: TPoint; Color: IBColor); 136 begin 137 Pixmap.Canvas.Pen.Color := (Color as TBColorGray1).Value; 138 Pixmap.Canvas.Pen.MoveTo(P1); 139 Pixmap.Canvas.Pen.LineTo(P2); 140 end; 141 134 142 procedure TBPixmapGray1.PaintToCanvas(Canvas: TCanvas); 135 143 begin -
branches/gbitmap/Packages/FastGraphics/ColorFormats/UColorGray2.pas
r24 r25 46 46 procedure Fill(Color: IBColor); override; 47 47 procedure Fill(Func: TGetColorPos); override; 48 procedure Line(P1, P2: TPoint; Color: IBColor); override; 48 49 procedure PaintToCanvas(Canvas: TCanvas); override; 49 50 function GetDataSize: Integer; override; … … 127 128 end; 128 129 130 procedure TBPixmapGray2.Line(P1, P2: TPoint; Color: IBColor); 131 begin 132 Pixmap.Canvas.Pen.Color := (Color as TBColorGray2).Value; 133 Pixmap.Canvas.Pen.MoveTo(P1); 134 Pixmap.Canvas.Pen.LineTo(P2); 135 end; 136 129 137 procedure TBPixmapGray2.PaintToCanvas(Canvas: TCanvas); 130 138 begin -
branches/gbitmap/Packages/FastGraphics/UFGraphics.pas
r24 r25 40 40 procedure Fill(Color: IBColor); virtual; overload; 41 41 procedure Fill(Func: TGetColorPos); virtual; overload; 42 procedure Line(P1, P2: TPoint; Color: IBColor); virtual; 42 43 procedure PaintToCanvas(Canvas: TCanvas); virtual; 43 44 function GetDataSize: Integer; virtual; … … 88 89 end; 89 90 91 IFColor = interface 92 end; 93 90 94 { TFColor } 91 95 92 TFColor = class 96 TFColor = class(TInterfacedObject, IFColor) 93 97 private 94 98 FBackend: IBColor; … … 105 109 end; 106 110 111 TFCanvas = class; 112 TFPixmap = class; 113 114 { TFBrush } 115 116 TFBrush = class 117 Color: IFColor; 118 Canvas: TFCanvas; 119 end; 120 121 { TFPen } 122 123 TFPen = class 124 Position: TPoint; 125 Color: IFColor; 126 Canvas: TFCanvas; 127 procedure MoveTo(Pos: TPoint); 128 procedure LineTo(Pos: TPoint); 129 end; 130 131 { TFCanvas } 132 133 TFCanvas = class 134 Pixmap: TFPixmap; 135 Pen: TFPen; 136 Brush: TFBrush; 137 constructor Create; 138 destructor Destroy; override; 139 end; 140 141 107 142 { TFPixmap } 108 143 … … 110 145 public 111 146 type 112 TGetColorPos = function (Position: TPoint; ColorFormat: TColorFormat): TFColor of object;147 TGetColorPos = function (Position: TPoint; ColorFormat: TColorFormat): IFColor of object; 113 148 private 114 149 FBackend: TBImage; 150 FCanvas: TFCanvas; 115 151 FColorFormat: TColorFormat; 116 152 FSize: TPoint; 117 153 FillCallBack: TGetColorPos; 118 154 function FillGetColor(Position: TPoint): IBColor; 119 function GetPixel(X, Y: Integer): TFColor;155 function GetPixel(X, Y: Integer): IFColor; 120 156 procedure SetColorFormat(AValue: TColorFormat); 121 procedure SetPixel(X, Y: Integer; AValue: TFColor);157 procedure SetPixel(X, Y: Integer; AValue: IFColor); 122 158 procedure SetSize(AValue: TPoint); 123 159 public 124 procedure Fill(Color: TFColor); overload;160 procedure Fill(Color: IFColor); overload; 125 161 procedure Fill(Func: TGetColorPos); overload; 126 162 procedure PaintToCanvas(Canvas: TCanvas); … … 128 164 constructor Create(AOwner: TComponent); override; 129 165 destructor Destroy; override; 166 property Canvas: TFCanvas read FCanvas; 130 167 property Backend: TBImage read FBackend; 131 168 property ColorFormat: TColorFormat read FColorFormat write SetColorFormat; 132 169 property Size: TPoint read FSize write SetSize; 133 property Pixels[X, Y: Integer]: TFColor read GetPixel write SetPixel;170 property Pixels[X, Y: Integer]: IFColor read GetPixel write SetPixel; 134 171 end; 135 172 … … 149 186 begin 150 187 RegisterComponents('FastGraphics', [TFPixmap]); 188 end; 189 190 { TFPen } 191 192 procedure TFPen.MoveTo(Pos: TPoint); 193 begin 194 Position := Pos; 195 end; 196 197 procedure TFPen.LineTo(Pos: TPoint); 198 begin 199 Canvas.Pixmap.Backend.Line(Position, Pos, (Color as TFColor).Backend); 200 Position := Pos; 201 end; 202 203 { TFCanvas } 204 205 constructor TFCanvas.Create; 206 begin 207 Pen := TFPen.Create; 208 Pen.Canvas := Self; 209 Brush := TFBrush.Create; 210 Brush.Canvas := Self; 211 end; 212 213 destructor TFCanvas.Destroy; 214 begin 215 FreeAndNil(Pen); 216 FreeAndNil(Brush); 217 inherited Destroy; 151 218 end; 152 219 … … 254 321 destructor TFColor.Destroy; 255 322 begin 323 FColorFormat := nil; 256 324 inherited Destroy; 257 325 end; … … 279 347 280 348 procedure TBImage.Fill(Func: TGetColorPos); 349 begin 350 end; 351 352 procedure TBImage.Line(P1, P2: TPoint; Color: IBColor); 281 353 begin 282 354 end; … … 309 381 function TFPixmap.FillGetColor(Position: TPoint): IBColor; 310 382 begin 311 Result := FillCallBack(Position, ColorFormat).Backend;312 end; 313 314 function TFPixmap.GetPixel(X, Y: Integer): TFColor;383 Result := (FillCallBack(Position, ColorFormat) as TFColor).Backend; 384 end; 385 386 function TFPixmap.GetPixel(X, Y: Integer): IFColor; 315 387 begin 316 388 Result := TFColor.Create; 317 Result.ColorFormat := ColorFormat;318 Result.FBackend := FBackend.Pixels[X, Y];319 end; 320 321 procedure TFPixmap.SetPixel(X, Y: Integer; AValue: TFColor);322 begin 323 FBackend.Pixels[X, Y] := AValue.FBackend;389 (Result as TFColor).ColorFormat := ColorFormat; 390 (Result as TFColor).FBackend := FBackend.Pixels[X, Y]; 391 end; 392 393 procedure TFPixmap.SetPixel(X, Y: Integer; AValue: IFColor); 394 begin 395 FBackend.Pixels[X, Y] := (AValue as TFColor).FBackend; 324 396 end; 325 397 … … 331 403 end; 332 404 333 procedure TFPixmap.Fill(Color: TFColor);334 begin 335 FBackend.Fill( Color.Backend);405 procedure TFPixmap.Fill(Color: IFColor); 406 begin 407 FBackend.Fill((Color as TFColor).Backend); 336 408 end; 337 409 … … 349 421 function TFPixmap.GetDataSize: Integer; 350 422 begin 351 FBackend.GetDataSize;352 end; 353 354 constructor TFPixmap.Create ;423 Result := FBackend.GetDataSize; 424 end; 425 426 constructor TFPixmap.Create(AOwner: TComponent); 355 427 begin 356 428 inherited; 429 FBackend := TBImage.Create; 430 FCanvas := TFCanvas.Create; 431 FCanvas.Pixmap := Self; 357 432 ColorFormat := ColorFormatManager.GetFormat(0); 358 FBackend := TBImage.Create;359 433 end; 360 434 361 435 destructor TFPixmap.Destroy; 362 436 begin 437 FreeAndNil(FCanvas); 363 438 FreeAndNil(FBackend); 364 439 inherited Destroy; -
branches/gbitmap/Packages/FastGraphics/UGGraphics.pas
r24 r25 192 192 ((Canvas as TGCanvas<TGColor>).Bitmap as TGPixmap<TGColor>).Pixels[Trunc(Position.X + I * (Pos.X - Position.X) / Len), 193 193 Trunc(Position.Y + I * (Pos.Y - Position.Y) / Len)] := Color; 194 Position := Pos; 194 195 end; 195 196 -
branches/gbitmap/UFormMain.pas
r24 r25 29 29 function RGB8Random(Position: TPoint): TColorRGB8; 30 30 function RGB16Random(Position: TPoint): TColorRGB16; 31 function ColorRandom(Position: TPoint; ColorFormat: TColorFormat): UFGraphics.TFColor;31 function ColorRandom(Position: TPoint; ColorFormat: TColorFormat): IFColor; 32 32 public 33 33 procedure TestGray1; … … 98 98 end; 99 99 100 function TForm1.ColorRandom(Position: TPoint; ColorFormat: TColorFormat): UFGraphics.TFColor;101 begin 102 Result := UFGraphics.TFColor.Create;103 Result.ColorFormat := ColorFormat;104 Result.SetRandom;100 function TForm1.ColorRandom(Position: TPoint; ColorFormat: TColorFormat): IFColor; 101 begin 102 Result := TFColor.Create; 103 (Result as TFColor).ColorFormat := ColorFormat; 104 (Result as TFColor).SetRandom; 105 105 end; 106 106 … … 276 276 with Image do begin 277 277 Size := Point(100, 100); 278 ColorFormat := ColorFormatManager.Formats[ 5];278 ColorFormat := ColorFormatManager.Formats[2]; 279 279 Fill(TFColor.Create(ColorFormat, cnWhite)); 280 Fill(ColorRandom); 280 281 Pixels[0, 0] := TFColor.Create(ColorFormat, cnBlack); 281 Fill(ColorRandom); 282 Canvas.Pen.Color := TFColor.Create(ColorFormat, cnBlack); 283 Canvas.Pen.MoveTo(Point(10, 20)); 284 Canvas.Pen.LineTo(Point(60, 40)); 282 285 PaintToCanvas(Image1.Picture.Bitmap.Canvas); 283 286 Label1.Caption := IntToStr(GetDataSize);
Note:
See TracChangeset
for help on using the changeset viewer.