Resources. How? lazarus / 9-Editor ---------------------------------------------------------------------- LazaruX · 2007-12-06 10:28 I would like to save a bitmap as a resource in my program and then when executing the program save that bitmap as a file. This is what I have done Textdocument created with: Code: [Select] Image BITMAP "foto.bmp" Saved the file as RES.RC and transformed it to .RES with WINDRES: Code: [Select] windres res.rc res.res This worked. Created a new project, Image1, button1 and button2 where placed on the form. In the onclick event of the button1 I have written: Code: [Select] Image1.Picture.Bitmap.Handle :=  LoadBitmap(hInstance, 'Image'); And I have added the Windows unit in the uses. In the onclick events of Buttno2 I have: Code: [Select] res := TResourceStream.Create(hInstance, 'Image', 'BITMAP'); res.SaveToFile('test.bmp'); res.Free; Code: [Select] res: TResourceStream; this variablle was placed globally. When I run the app, the image is loaded fine in the Image1 component, but when I pres Button 2 I get an error. How do I save a resource to a file? Thanks ---------------------------------------------------------------------- LazaruX · 2007-12-06 10:45 The error i get is the following: First it says: Project raised exception class "EresNotFound" Then: The file stream.inc was not fount, do you want to locate it yourself? ---------------------------------------------------------------------- Marc · 2007-12-06 11:12 2 things possible: 1: TResourceStream only read lazarus stream (look at implementaation if tresourcestream) 2: you didn't include the res in your project ($R res.res) ---------------------------------------------------------------------- LazaruX · 2007-12-06 11:16 This is the code now: PS: the {$R Res.RES} was already added. Code: [Select] unit Unit1; {$mode objfpc}{$H+} interface {$IFDEF WIN32}{$R Res.RES}{$ENDIF} uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,dos,crt,windows,   ExtCtrls, ComCtrls, EditBtn; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Button2: TButton;     Image1: TImage;     procedure Button1Click(Sender: TObject);     procedure Button2Click(Sender: TObject);     procedure FormCreate(Sender: TObject);     procedure FormPaint(Sender: TObject);     procedure FormShow(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1;     i:integer;     res: TResourceStream; implementation { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin Image1.Picture.Bitmap.Handle :=  LoadBitmap(hInstance, 'Image'); end; procedure TForm1.Button2Click(Sender: TObject); begin res := TResourceStream.Create(hInstance, 'Image', 'BITMAP'); res.SaveToFile('test.bmp'); res.Free;   end; procedure TForm1.FormCreate(Sender: TObject); begin end; procedure TForm1.FormPaint(Sender: TObject); begin end; procedure TForm1.FormShow(Sender: TObject); begin end; initialization   {$I Unit1.lrs} end. ---------------------------------------------------------------------- LazaruX · 2007-12-07 10:22 And I still get an error, it just does not work ---------------------------------------------------------------------- LazaruX · 2007-12-10 12:56 This is how I have temporally solved the problem: Code: [Select]          Image1.Picture.Bitmap.Handle :=  LoadBitmap(hInstance, 'Image');          image1.Picture.SaveToFile('n.bmp'); hoping to get another solution from somebody Bye ---------------------------------------------------------------------- Marc · 2007-12-10 13:27 From this I think TResourceStream only read lazarus stream. But you can only know if you look in the source (i've no source here)