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.026 c
4-22480
amamed_3071
2001-11-03 10:09
2002.01.08
Print to Epson printer


1-22230
Man in red
2001-12-15 23:01
2002.01.08
How to display a serial number in RichEdite of the selected character in labele!


6-22266
PHN
2001-10-02 14:50
2002.01.08
Connect


1-22125
Dimass
2001-12-19 23:34
2002.01.08
Help me to understand.....


14-22336
Ivan Shikhalev
2001-11-02 23:31
2002.01.08
Golden banana





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