Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

Upload jpg file to image Find similar branches


Angel S   (2001-12-15 23:04) [0]

Can I upload an image to Jpg from a resource file in Image ...
If so, how ???



Virtualik   (2001-12-15 23:53) [1]

Procedure LoadJPEGFromRes (TheJPEG: string; var ThePicture: TPicture); var ResHandle: THandle; MemHandle: THandle; MemStream: TMemoryStream; ResPtr: PByte; ResSize: Longint; JPEGImage: TJPEGImage; begin ResHandle: = FindResource (hInstance, PChar (TheJPEG), "JPEG"); MemHandle: = LoadResource (hInstance, ResHandle); ResPtr: = LockResource (MemHandle); MemStream: = TMemoryStream.Create; JPEGImage: = TJPEGImage.Create; ResSize: = SizeOfResource (hInstance, ResHandle); MemStream. SetSize (ResSize); MemStream.Write (ResPtr ^, ResSize); FreeResource (MemHandle); MemStream.Seek (0, 0); JPEGImage.LoadFromStream (MemStream); ThePicture.Assign (JPEGImage); JPEGImage.Free; MemStream.Free; end;



Angel S   (2001-12-16 13:00) [2]

Gives error JPEG error #41
What could be the error ???



Мефодий   (2001-12-16 22:42) [3]

I bring a piece of code from my program, where I pull out a picture from the resource file Myres.rc with a Jpeg file:

procedure TMyForm.FormCreate (Sender: TObject);
var temp_jpeg: TJPEGImage;
ResStream: TResourceStream;
begin
.....
temp_jpeg: = TJpegImage.Create;
ResStream: = TResourceStream.CreateFromID (HInstance, 1, RT_RCDATA);
temp_jpeg.LoadFromStream (ResStream);
.....
temp_jpeg.Free;
ResStream.Free;
.....
end;

I would be glad if I helped with anything.

PS
Contents of Myres.rc

1 RCDATA "Myimage.jpg"
.......



Angel S   (2001-12-17 16:52) [4]

I connect the compiled resource file (res), but rc cannot connect, because he says he does not support 16-bit resource files ....
Connect using
{$ R Myres.rc}



Angel S   (2001-12-17 16:53) [5]

when MyRes.res is connected, an error appears in this line:
ResStream: = TResourceStream.CreateFromID (HInstance, 1, RT_RCDATA);



Dimka Maslov   (2001-12-17 17:02) [6]

In the shape of
procedure TAboutForm.FormCreate (Sender: TObject); var RS: TResourceStream; JP: TJPEGImage; begin RS: = nil; JP: = nil; try RS: = TResourceStream.Create (hInstance, "ABOUT", "JPEG"); JP: = TJPEGImage.Create; JP.LoadFromStream (RS); JP.DIBNeeded; Image.Picture.Bitmap.Assign (JP); finally RS.Free; JP.Free; end; end;

In rc file
ABOUT JPEG ABOUT.JPG

You need to add an rc-file to the project through the menu Project> Add To Project



Angel S   (2001-12-18 19:58) [7]

Everything worked ... Thank you very much !!!



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top









Memory: 0.57 MB
Time: 0.024 c
14-22323
Melamed
2001-11-04 19:57
2002.01.08
How to correct these personal data, registered at registration?


3-21936
ks
2001-12-05 06:42
2002.01.08
Delphi5 + SQL Server7 is fine, and Delphi5 + SQL 2000 is nonsense


1-22241
Yuraz
2001-12-17 10:09
2002.01.08
FileListBox1.FileName returns the full path to the file, how to make it return only the file name?


14-22410
fint
2001-11-08 15:10
2002.01.08
Try


1-22250
Dmitry D.
2001-12-17 13:28
2002.01.08
Rather a mathematical question ...





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish