Re: Add my own bitmaps into a resource file?



On 16 Sep, 21:48, "Somebody" <S...@xxxxxxxxx> wrote:
Hello,

I want to use a resource file to load my own bitmaps. Previously I have been
using loadfromfile but want to get away from that.

However, I can set up the resource file but it only appears to let me create
a new bitmap. I already have some ready but just can't see the option to add
them. Is it possible? Thanks.

I have the version 3.0 Image editor.

Create a text file with the name of the resource file you will require
(but NOT the same as your .pas file) and a .rc extension. for
example ...

SpeechMike.rc contents
SM1Pro BITMAP "..\Bitmaps\SM1Pro.bmp"
SM1ProBarcode BITMAP "..\Bitmaps\SM1ProBarCode.bmp"
SM1Classic BITMAP "..\Bitmaps\SM1Classic.bmp"

Note the file path names delimited with double quotes for long
filenames. The double quotes are not necessary for an 8.3 short
filename. Double dots mean the parent folder.

Then call BRCC32.exe as follows ...

BRCC32 /v SpeechMike.rc

This would produce a file SpeechMike.res in the same folder as
BRCC32.exe

Then place a {$R <filename> } compiler directive with the resource
file name in the implementation clause of your unit ...

{$R '..\Resources\Compiled Resources\SpeechMike.res'}

In your code declare a bitmap variable and create the bitmap in
code ...

var
FMiniBitMap : TBitmap;

begin
FMiniBitMap := TBitmap.Create;

Then load the bitmap from the resource by allocating the handle
returned from a LoadBitmap() function ...

FMiniBitmap.Handle := LoadBitmap(HInstance, 'SM1ProBarCode');

Resource access is sometimes twitchy regarding identical cases in the
resource name or type, and in the file.

You could also get at the bitmap in a resource by using a
TResourceStream.

Alan Lloyd




.



Relevant Pages

  • Re: Load a resource from any namespace in project?
    ... It depends what kind of resource you want to load. ... bitmap it constructor has an ovreload that accepts Type object. ... used only to get the name of the namespace. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: GDI Bitmap Prob.
    ... The "required resource not found" is a message which should be findable in the MFC source ... >the OnDraw() and Draw the data needed. ... >stretching the bitmap ... >> rendered does not declare a CPaintDC, you first render the bitmap and then ...
    (microsoft.public.vc.mfc)
  • Re: Bitmaps
    ... > I need to load a bitmap from a resource, scale it to a given x,y size, ...
    (microsoft.public.win32.programmer.gdi)
  • Re: CStatic control image repaint problem
    ... Dont know what would cause this. ... > I use the SetBitmap function to load the image in the CStatic which I ... > Also I dont have the bitmap as a resource. ... A CStatic is also a picture control that you see in resource ...
    (microsoft.public.vc.mfc)
  • Re: How to fill a Rectangle with a Bitmap Resource using GDI+
    ... I AM using a GDI+ Bitmap. ... GDI+ and it doesn't look like it is possible to do this in GDI+. ... Either use the gdi+ API to load and/or create your bitmap's or use the ... The problem is painting a bitmap/image as a brush from a resource. ...
    (microsoft.public.win32.programmer.gdi)