[Overview][Classes][Index] Reference for unit 'bitmapresource' (#fcl-res)

TBitmapResource.SetCustomBitmapDataStream

Sets a custom stream as the underlying stream for BitmapData

Declaration

Source position: bitmapresource.pp line 46

public procedure TBitmapResource.SetCustomBitmapDataStream(

  aStream: TStream

);

Arguments

aStream

  

The custom stream to use as the underlying BitmapData stream

Description

This method allows the user to use a custom stream as the underlying stream for BitmapData. This is useful when you want a TBitmapResource to be created from a bmp file for which you have a stream.

Sample code

This code creates a resource containing a bitmap

var
  aName : TResourceDesc;
  aRes : TBitmapResource;
  aFile : TFileStream;
  Resources : TResources;
begin
  Resources:=TResources.Create;
  aName:=TResourceDesc.Create('MYBITMAP');
  aRes:=TBitmapResource.Create(nil,aName); //type is always RT_BITMAP
  aName.Free; //not needed anymore
  aFile:=TFileStream.Create('mybitmap.bmp',fmOpenRead or fmShareDenyNone);
  aRes.SetCustomBitmapDataStream(aFile);
  Resources.Add(aRes);
  Resources.WriteToFile('myresource.res');

  Resources.Free; //it destroys aRes as well.
  aFile.Free;
end;

See also

TBitmapResource.BitmapData

  

Resource data as a BMP stream

TAbstractResource.UpdateRawData

  

Updates RawData stream.


Documentation generated on: May 14 2021