howto compile a bitmap in your program?

How can I get a bitmap into a nonvisual component. I want to compile a bitmap in the component so that it is a static graphic wich I can use...

Anyone, please,

Martijn
mtielandAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MotazCommented:
The best way I think is to drop an image component, load a bitmap on it and set it's visible property to false, then you can use it later at run time, for example

//Store the pitmap in MyHiddenImage TImage component

Image1.Picture.Bitmap.Assign(MyHiddenImage.Picture.Bitmap);

Motaz

www.geocities.com/motaz1
0
MotazCommented:
If you do so, the bitmap will be stored in your exe file.
0
mtielandAuthor Commented:
The problem is I am making a Desendant from TComponent and need to store the image in the class... I want to make a Active X Control eventually...

0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

MotazCommented:
I see, then you have to use another technique which I'm not sure about, may be a resource file, streams and so on, let the experts answer you.

Motaz
0
mtielandAuthor Commented:
another good solution would be to load the image from a webserver, if anyone has an easy to use component to do just that. That would solve my problem too..
0
hubdogCommented:
you can put bitmap into a res file
and use tresourestream to load it in your program .And if you want make a activex control,may be you should make your control inherited from twincontrol

good luck

hubdog
0
mtielandAuthor Commented:
can you explain some more about that resource file thing...
0
DrDelphiCommented:
I have a good example of how to make and use a resource file on my website...
www.drdelphi.com. Look under sample codes and then the snippet is An AVI resource example.... or go directly to:

http://www.drdelphi.com/delphi/right/tips/avires.htm



Good luck!!
0
hubdogCommented:
for example
you can use image editor shipped with delphi.Use menu File|New|resource file
and then new a bitmap,and edit it.Then you can copy a exist bitmap to the empty bitmap and save it to an res id such as bitmap1.Finally save your res file (name such as your.res)

then in your control written like this

unit YouControl;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TYouControl = class(TWincontrol)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
    procedure LoadyouBitmap;
  published
    { Published declarations }
  end;

procedure Register;

implementation

{$r your.res}//that is key include the resfile you already create

procedure Register;
begin
  RegisterComponents('CX Lib', [TYouControl]);
end;

{ TYouControl }

procedure TYouControl.LoadyouBitmap;
begin
  if loadbitmap(hinstance,'BITMAP1')<>NULL then
    showmessage('ok');
//also you can use tresourcestream.create(hinstance,'BITMAP1','RT_BITMAP'); to replace loadbitmap      
end;

end.

this is a demo to test the loadbitmap

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, YouControl;

type
  TForm1 = class(TForm)
    YouControl1: TYouControl;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  youcontrol1.LoadyouBitmap;
end;

end.

good luck

hubdog
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mtielandAuthor Commented:
Thanx a lot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.