Download Now
Forums

    Reference IResourceStore

    Declared in Codebot.Render.Graphics.pas on line 472

    IResourceStore is associated with a canvas, and allows for the creation and management of bitmap and font resources. Resoruces are tracked by name, and subsequent requests using the same name return an existing resource rather than loading the same resource mutliple times.
      IResourceStore = interface
      public
        { Create a text writer given a font }
        function NewTextWriter(Font: IFont): ITextWriter; overload;
        { Create a text writer given a font and a page }
        function NewTextWriter(Font: IFont; Page: TRectF; Margin: TVec2): ITextWriter; overload;
        { Create a new render bitmap, checking the store first if a render bitmap
          with a matching name already exists. }
        function NewBitmap(const Name: string; Width, Height: LongWord): IRenderBitmap;
        { Check the store if a image exists using name as a the key. If name is not
          found then nil is returned. }
        function LoadBitmap(const Name: string): IBitmap; overload;
        { Check the store if an image already exists. If not found load a new jpg,
          png, psd, tga, pic or gif image from a file or memory and associated it
          with the store using name as a key. When Mipmaps is true a new image is
          given mipmaps, so it stays smooth when drawn much smaller than its size.
          An image already in the store is returned as it was loaded. }
        function LoadBitmap(const Name: string; FileName: string; Mipmaps: Boolean = False): IBitmap; overload;
        { Load the image from memory }
        function LoadBitmap(const Name: string; Memory: Pointer; Size: LongWord; Mipmaps: Boolean = False): IBitmap; overload;
        { Load the image from the pixels of bitmap data, such as the result of
          ResampleBitmap. The pixels are copied, so the bitmap data can be changed
          or released afterwards. }
        function LoadBitmap(const Name: string; Data: IBitmapData; Mipmaps: Boolean = False): IBitmap; overload;
        { Load the image from a resource of the program }
        function LoadBitmapResource(const Name, ResName: string; Mipmaps: Boolean = False): IBitmap;
        { Load the image from an asset of the program, which is in its dat file or
          is a file in its assets folder. AssetName is the path of the image below
          the assets folder, such as 'cards/table.jpg'. See Codebot.Render.Assets. }
        function LoadBitmapAsset(const Name, AssetName: string; Mipmaps: Boolean = False): IBitmap;
        { Release space used by a bitmap and dispose of the underlying resources. }
        procedure DisposeBitmap(Bitmap: IBitmap);
        { Check the store if a font exists using name as a the key. If name is not
          found then nil is returned. }
        function LoadFont(const Name: string): IFont; overload;
        { Check the store if a font already exists. If not found load a new font
          from a file or memory and associated it with the store using name as a key }
        function LoadFont(const Name: string; FileName: string): IFont; overload;
        { Load the font from memory }
        function LoadFont(const Name: string; Memory: Pointer; Size: LongWord): IFont; overload;
        { Load the font from a resource of the program }
        function LoadFontResource(const Name, ResName: string): IFont;
        { Load the font from an asset of the program, which is in its dat file or is
          a file in its assets folder. AssetName is the path of the font below the
          assets folder, such as 'fonts/roboto.ttf'. }
        function LoadFontAsset(const Name, AssetName: string): IFont;
      end;

    See also

    IBitmapData in Codebot.Platform.pas
    TRectF in Codebot.Graphics.Types.pas
    TVec2 in Codebot.Geometry.pas