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.56 MB
Time: 0.022 c
6-22273
Denis Titov
2001-10-06 11:50
2002.01.08
Building local networks


6-22303
maxi
2001-10-11 18:03
2002.01.08
The DCOM client does not see the DCOM server on different machines.


14-22353
Merlin
2001-11-02 10:13
2002.01.08
I'm shocked


1-22074
Bb
2001-12-17 21:28
2002.01.08
HELP !!!!


1-22080
Delphimun
2001-12-18 17:11
2002.01.08
How to load the cursor from the resource, and then save it to disk?





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 Spanish 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