Changeset 39 for trunk/Packages
- Timestamp:
- Oct 10, 2018, 3:48:47 PM (6 years ago)
- Location:
- trunk/Packages/FastGraphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/FastGraphics/ColorFormats/UColorGray1.pas
r32 r39 36 36 { TBPixmapGray1 } 37 37 38 TBPixmapGray1 = class(TB Image)38 TBPixmapGray1 = class(TBPixmap) 39 39 private 40 40 FillCallBack: TGetColorPos; … … 73 73 BitDepth := 1; 74 74 BackendColorClass := TBColorGray1; 75 Backend ImageClass := TBPixmapGray1;75 BackendPixmapClass := TBPixmapGray1; 76 76 AddChannel('Gray', 0, 1); 77 77 end; -
trunk/Packages/FastGraphics/ColorFormats/UColorGray2.pas
r30 r39 35 35 { TBPixmapGray2 } 36 36 37 TBPixmapGray2 = class(TB Image)37 TBPixmapGray2 = class(TBPixmap) 38 38 private 39 39 FillCallBack: TGetColorPos; … … 71 71 BitDepth := 2; 72 72 BackendColorClass := TBColorGray2; 73 Backend ImageClass := TBPixmapGray2;73 BackendPixmapClass := TBPixmapGray2; 74 74 AddChannel('Gray', 0, 2); 75 75 end; -
trunk/Packages/FastGraphics/ColorFormats/UColorGray4.pas
r30 r39 31 31 procedure SetColorName(ColorName: TColorName); override; 32 32 procedure SetRandom; override; 33 procedure SetColor(Color: TColor); override; 33 34 end; 34 35 35 36 { TBPixmapGray4 } 36 37 37 TBPixmapGray4 = class(TB Image)38 TBPixmapGray4 = class(TBPixmap) 38 39 private 39 40 FillCallBack: TGetColorPos; 40 41 function FillGetColor(Position: TPoint): TColorGray4; 42 function NegativeFunc(Position: TPoint): TColorGray4; 41 43 protected 42 44 procedure SetSize(AValue: TPoint); override; … … 45 47 public 46 48 Pixmap: TPixmapGray4; 49 procedure Flip; override; 50 procedure Mirror; override; 51 procedure Negative; override; 47 52 procedure Fill(Color: IBColor); override; 48 53 procedure Fill(Func: TGetColorPos); override; … … 70 75 BitDepth := 4; 71 76 BackendColorClass := TBColorGray4; 72 Backend ImageClass := TBPixmapGray4;77 BackendPixmapClass := TBPixmapGray4; 73 78 AddChannel('Gray', 0, 4); 74 79 end; … … 110 115 end; 111 116 117 procedure TBColorGray4.SetColor(Color: TColor); 118 begin 119 Value := ((Color shr 0) and $ff + (Color shr 8) and $ff + (Color shr 16) and $ff) div (3 * 16); 120 end; 121 112 122 { TBPixmapGray2 } 113 123 … … 115 125 begin 116 126 Result := (FillCallBack(Position) as TBColorGray4).Value; 127 end; 128 129 function TBPixmapGray4.NegativeFunc(Position: TPoint): TColorGray4; 130 var 131 C: TColorGray4; 132 begin 133 C := Pixmap.Pixels[Position.X, Position.Y]; 134 Result := 16 - (C and $f); 117 135 end; 118 136 … … 131 149 begin 132 150 Pixmap.Pixels[X, Y] := (AValue as TBColorGray4).Value; 151 end; 152 153 procedure TBPixmapGray4.Flip; 154 begin 155 Pixmap.Flip; 156 end; 157 158 procedure TBPixmapGray4.Mirror; 159 begin 160 Pixmap.Mirror; 161 end; 162 163 procedure TBPixmapGray4.Negative; 164 begin 165 Pixmap.Fill(NegativeFunc); 133 166 end; 134 167 -
trunk/Packages/FastGraphics/ColorFormats/UColorRGB8.pas
r36 r39 43 43 { TBPixmapRGB8 } 44 44 45 TBPixmapRGB8 = class(TB Image)45 TBPixmapRGB8 = class(TBPixmap) 46 46 private 47 47 FillCallBack: TGetColorPos; … … 81 81 BitDepth := 24; 82 82 Name := 'RGB8'; 83 Backend ImageClass := TBPixmapRGB8;83 BackendPixmapClass := TBPixmapRGB8; 84 84 BackendColorClass := TBColorRGB8; 85 85 AddChannel('Red', 0, 8); -
trunk/Packages/FastGraphics/UFGraphics.pas
r36 r39 27 27 IBColorClass = class of TBColor; 28 28 29 { TB Image}30 31 TB Image= class29 { TBPixmap } 30 31 TBPixmap = class 32 32 public 33 33 type … … 57 57 end; 58 58 59 TBPixmapClass = class of TB Image;59 TBPixmapClass = class of TBPixmap; 60 60 61 61 { TColorFormatChannel } … … 74 74 Channels: array of TColorFormatChannel; 75 75 BackendColorClass: IBColorClass; 76 Backend ImageClass: TBPixmapClass;76 BackendPixmapClass: TBPixmapClass; 77 77 procedure AddChannel(Name: string; Position, BitWidth: Integer); 78 78 function GetBackendColor: IBColor; 79 function GetBackendImage: TB Image;79 function GetBackendImage: TBPixmap; 80 80 constructor Create; virtual; 81 81 function GetChannelStateCount(Channel: Integer): Integer; … … 117 117 procedure SetColorName(ColorName: TColorName); 118 118 procedure SetRandom; 119 procedure SetColor(Color: TColor); 119 120 constructor Create; overload; 120 121 constructor Create(ColorFormat: TColorFormat; ColorName: TColorName); overload; … … 161 162 TGetColorPos = function (Position: TPoint; ColorFormat: TColorFormat): IFColor of object; 162 163 private 163 FBackend: TB Image;164 FBackend: TBPixmap; 164 165 FCanvas: TFCanvas; 165 166 FColorFormat: TColorFormat; … … 190 191 destructor Destroy; override; 191 192 property Canvas: TFCanvas read FCanvas; 192 property Backend: TB Imageread FBackend;193 property Backend: TBPixmap read FBackend; 193 194 property ColorFormat: TColorFormat read FColorFormat write SetColorFormat; 194 195 property Size: TPoint read FSize write SetSize; … … 313 314 end; 314 315 315 function TColorFormat.GetBackendImage: TB Image;316 begin 317 Result := Backend ImageClass.Create;316 function TColorFormat.GetBackendImage: TBPixmap; 317 begin 318 Result := BackendPixmapClass.Create; 318 319 end; 319 320 … … 323 324 BitDepth := 0; 324 325 BackendColorClass := TBColor; 325 Backend ImageClass := TBImage;326 BackendPixmapClass := TBPixmap; 326 327 end; 327 328 … … 350 351 end; 351 352 353 procedure TFColor.SetColor(Color: TColor); 354 begin 355 Backend.SetColor(Color); 356 end; 357 352 358 constructor TFColor.Create; 353 359 begin … … 373 379 end; 374 380 375 { TB Image}376 377 function TB Image.GetPixel(X, Y: Integer): IBColor;381 { TBPixmap } 382 383 function TBPixmap.GetPixel(X, Y: Integer): IBColor; 378 384 begin 379 385 Result := TBColor.Create; 380 386 end; 381 387 382 procedure TB Image.SetPixel(X, Y: Integer; AValue: IBColor);383 begin 384 end; 385 386 procedure TB Image.SetSize(AValue: TPoint);388 procedure TBPixmap.SetPixel(X, Y: Integer; AValue: IBColor); 389 begin 390 end; 391 392 procedure TBPixmap.SetSize(AValue: TPoint); 387 393 begin 388 394 if (FSize.X = AValue.X) and (FSize.Y = AValue.Y) then Exit; … … 390 396 end; 391 397 392 procedure TB Image.Mirror;393 begin 394 end; 395 396 procedure TB Image.Flip;397 begin 398 end; 399 400 procedure TB Image.Negative;401 begin 402 end; 403 404 procedure TB Image.Fill(Color: IBColor);405 begin 406 end; 407 408 procedure TB Image.Fill(Func: TGetColorPos);409 begin 410 end; 411 412 procedure TB Image.Line(P1, P2: TPoint; Color: IBColor);413 begin 414 end; 415 416 procedure TB Image.PaintToCanvas(Canvas: TCanvas);417 begin 418 end; 419 420 procedure TB Image.PaintToCanvas(Canvas: TCanvas; Rect: TRect);421 begin 422 end; 423 424 procedure TB Image.PaintToBitmap(Bitmap: TBitmap; Rect: TRect);425 begin 426 end; 427 428 procedure TB Image.LoadFromCanvas(Canvas: TCanvas);429 begin 430 end; 431 432 procedure TB Image.LoadFromBitmap(Bitmap: TBitmap);433 begin 434 end; 435 436 function TB Image.GetDataSize: Integer;398 procedure TBPixmap.Mirror; 399 begin 400 end; 401 402 procedure TBPixmap.Flip; 403 begin 404 end; 405 406 procedure TBPixmap.Negative; 407 begin 408 end; 409 410 procedure TBPixmap.Fill(Color: IBColor); 411 begin 412 end; 413 414 procedure TBPixmap.Fill(Func: TGetColorPos); 415 begin 416 end; 417 418 procedure TBPixmap.Line(P1, P2: TPoint; Color: IBColor); 419 begin 420 end; 421 422 procedure TBPixmap.PaintToCanvas(Canvas: TCanvas); 423 begin 424 end; 425 426 procedure TBPixmap.PaintToCanvas(Canvas: TCanvas; Rect: TRect); 427 begin 428 end; 429 430 procedure TBPixmap.PaintToBitmap(Bitmap: TBitmap; Rect: TRect); 431 begin 432 end; 433 434 procedure TBPixmap.LoadFromCanvas(Canvas: TCanvas); 435 begin 436 end; 437 438 procedure TBPixmap.LoadFromBitmap(Bitmap: TBitmap); 439 begin 440 end; 441 442 function TBPixmap.GetDataSize: Integer; 437 443 begin 438 444 Result := 0; 439 445 end; 440 446 441 constructor TB Image.Create;447 constructor TBPixmap.Create; 442 448 begin 443 449 Size := Point(0, 0); … … 503 509 504 510 procedure TFPixmap.Gradient; 505 begin 506 511 var 512 X, Y: Integer; 513 Color: IFColor; 514 begin 515 Color := TFColor.Create; 516 (Color as TFColor).ColorFormat := ColorFormat; 517 for Y := 0 to Size.Y div 4 - 1 do 518 for X := 0 to Size.X - 1 do begin 519 (Color as TFColor).SetColor(RGBToColor( 520 Trunc(X / Size.X * 256), 521 0, 522 0 523 )); 524 Pixels[X, Y] := Color; 525 end; 526 for Y := Size.Y div 4 to 2 * Size.Y div 4 - 1 do 527 for X := 0 to Size.X - 1 do begin 528 (Color as TFColor).SetColor(RGBToColor( 529 0, 530 Trunc(X / Size.X * 256), 531 0 532 )); 533 Pixels[X, Y] := Color; 534 end; 535 for Y := 2 * Size.Y div 4 to 3 * Size.Y div 4 - 1 do 536 for X := 0 to Size.X - 1 do begin 537 (Color as TFColor).SetColor(RGBToColor( 538 0, 539 0, 540 Trunc(X / Size.X * 256) 541 )); 542 Pixels[X, Y] := Color; 543 end; 544 for Y := 3 * Size.Y div 4 to Size.Y - 1 do 545 for X := 0 to Size.X - 1 do begin 546 (Color as TFColor).SetColor(RGBToColor( 547 Trunc(X / Size.X * 256), 548 Trunc(X / Size.X * 256), 549 Trunc(X / Size.X * 256) 550 )); 551 Pixels[X, Y] := Color; 552 end; 507 553 end; 508 554 … … 561 607 begin 562 608 inherited; 563 FBackend := TB Image.Create;609 FBackend := TBPixmap.Create; 564 610 FCanvas := TFCanvas.Create; 565 611 FCanvas.Pixmap := Self;
Note:
See TracChangeset
for help on using the changeset viewer.