Changeset 7 for trunk/UGraphic.pas


Ignore:
Timestamp:
Sep 19, 2014, 9:25:56 AM (10 years ago)
Author:
chronos
Message:
  • Added: Mono image color format. Pixels/channels with lower size then byte are not supported yet.
  • Added: Slow image flip and mirror operation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UGraphic.pas

    r5 r7  
    2222    function GetPixelSize: Integer; virtual;
    2323    function GetName: string; virtual;
    24     function GetChannelBytePos(Channel: TGColorChannel): Integer; virtual;
     24    function GetChannelBitPos(Channel: TGColorChannel): Integer; virtual;
    2525    function GetChannelBitWidth(Channel: TGColorChannel): Integer; virtual;
    2626    function ChannelUsed(Channel: TGColorChannel): Boolean;
     
    7575    procedure Clear;
    7676    procedure Random;
     77    procedure Flip;
     78    procedure Mirror;
    7779    constructor Create; virtual;
    7880    destructor Destroy; override;
     
    242244end;
    243245
    244 function TGColorFormat.GetChannelBytePos(Channel: TGColorChannel): Integer;
     246function TGColorFormat.GetChannelBitPos(Channel: TGColorChannel): Integer;
    245247begin
    246248
     
    437439end;
    438440
     441procedure TGBitmap.Flip;
     442var
     443  X, Y: Integer;
     444  Color: TGColor;
     445begin
     446  for Y := 0 to Size.Y div 2 - 1 do
     447    for X := 0 to Size.X - 1 do begin
     448      Color := Pixels[X, Y];
     449      Pixels[X, Y] := Pixels[X, Size.Y - 1 - Y];
     450      Pixels[X, Size.Y - 1 - Y] := Color;
     451      Color.Free;
     452    end;
     453end;
     454
     455procedure TGBitmap.Mirror;
     456var
     457  X, Y: Integer;
     458  Color: TGColor;
     459begin
     460  for Y := 0 to Size.Y - 1 do
     461    for X := 0 to Size.X div 2 - 1 do begin
     462      Color := Pixels[X, Y];
     463      Pixels[X, Y] := Pixels[Size.X - 1 - X, Y];
     464      Pixels[Size.X - 1 - X, Y] := Color;
     465      Color.Free;
     466    end;
     467end;
     468
    439469constructor TGBitmap.Create;
    440470begin
Note: See TracChangeset for help on using the changeset viewer.