Ignore:
Timestamp:
Jan 5, 2017, 11:48:36 PM (8 years ago)
Author:
chronos
Message:
  • Added: Remember last used image size and color format.
  • Added: Automatically create blank image.
Location:
trunk/Packages/FastGraphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/FastGraphics/UFGraphics.pas

    r31 r33  
    66
    77uses
    8   Classes, SysUtils, Graphics, UGGraphics, UPixmapSpecialized, Contnrs;
     8  Classes, SysUtils, Graphics, UGGraphics, UPixmapSpecialized, Fgl;
    99
    1010type
     
    8181  end;
    8282
     83  TColorFormats  = class(TFPGObjectList<TColorFormat>)
     84  end;
     85
    8386  TColorFormatClass = class of TColorFormat;
    8487
     
    8790  TColorFormatManager = class
    8891  private
    89     FFormats: TObjectList; // TList<TColorFormat>
     92    FFormats: TColorFormats;
    9093    function GetFormat(Index: Integer): TColorFormat;
    9194  public
    9295    constructor Create; virtual;
    93      destructor Destroy; override;
     96    destructor Destroy; override;
     97    function FindByName(Name: string): Integer;
    9498    procedure RegisterFormat(Format: TColorFormatClass);
    9599    function FormatCount: Integer;
    96     property Formats[Index: Integer]: TColorFormat read GetFormat;
     100    property Formats: TColorFormats read FFormats;
    97101  end;
    98102
     
    261265constructor TColorFormatManager.Create;
    262266begin
    263   FFormats := TObjectList.Create;
     267  FFormats := TColorFormats.Create;
    264268end;
    265269
     
    268272  FreeAndNil(FFormats);
    269273  inherited Destroy;
     274end;
     275
     276function TColorFormatManager.FindByName(Name: string): Integer;
     277var
     278  I: Integer;
     279begin
     280  Result := -1;
     281  for I := 0 to FFormats.Count - 1 do begin
     282    if FFormats[I].Name = Name then begin
     283      Result := I;
     284      Break;
     285    end;
     286  end;
    270287end;
    271288
  • trunk/Packages/FastGraphics/UGGraphics.pas

    r31 r33  
    203203  PixelPtrMin: PInteger;
    204204  PixelRowPtr: PInteger;
    205   P: TPixelFormat;
    206205  RawImage: TRawImage;
    207206  BytePerPixel: Integer;
     
    218217      for X := Rect.Left to Rect.Right - 1 do begin
    219218        if (X >= 0) and (X < FSize.X) and (Y >= 0) and (Y < FSize.Y) and
    220         (PixelPtr < PixelPtrMax) and (PixelPtr > PixelPtrMin) then
     219        (PixelPtr < PixelPtrMax) and (PixelPtr >= PixelPtrMin) then begin
    221220          PixelPtr^ := ColorConvertFunc(Pixels[X, Y]);
     221        end;
    222222        Inc(PByte(PixelPtr), BytePerPixel);
    223 
    224223      end;
    225224      Inc(PByte(PixelRowPtr), RawImage.Description.BytesPerLine);
Note: See TracChangeset for help on using the changeset viewer.