How can i load TImage picture from a TMemoryStream that contain TJpeg data?

"Ahmadi" wrote in message

> How can i load TImage picture from a TMemoryStream that contain TJpeg
> data

You have to load the TMemoryStream into a TJPEGImage, and then you can
Assign() that to the TImage.Picture property.

> jp:=TJPEGImage.Create;

Since you already have the TJPEGImage, you can get rid of the TMemoryStream
completely, ie:

jp: TJPEGImage;
jp := TJPEGImage.Create;


Posted On: Tuesday 16th of October 2012 03:49:58 AM Total Views:  248
View Complete with Replies

Related Messages:

How can I do to remove the Delphi compiler message "Return value of function 'MyFunction' might be undefined" ?   (336 Views)
Before to modify my "old" delphi code, I would like to know if there is a different way to remove the Delphi compiler message "Return value of function 'MyFunction' might be undefined". For example, here is some code that generates this warning message : .... type TrvSampleType = (stTwo, stThree); ..... function GetSampleType(AValue: Integer):TrvSampleType; begin if (AValue Mod 2 = 0) then Result := stTwo else if (AValue Mod 3 = 0) then Result := stThree; end; What I should write is something like that : type TrvSampleType = (stNone, stTwo, stThree); ..... function GetSampleType(AValue: Integer):TrvSampleType; begin if (AValue Mod 2 = 0) then Result := stTwo else if (AValue Mod 3 = 0) then Result := stThree else Result := stNone; end; But in fact, I don't want to add a new sample type value like a stNone, so how can I assign a "null" value to the Result var to avoid the warning Delphi message Thank you for your help. Laurent
Triton 1880 KW barcode scanner   (165 Views)
Has anyone written a barcode scanning application using Triton 1880 KW barcode scanner There is a demo app called CBScanner.exe and it works fine, but I can't see a way or find any info about integrating it with the app. The set uses Windows Mobile 2003.
D2007 cannot resolve Forms   (290 Views)
I'm a bit puzzled about D2007. I have a project which *is* compiling and executes. But the IDE keeps on complaining about an 'unresolved unit Forms' and proceeds to treat any items exported from the Forms unit as errors. D2007 compiles ok. The project runs without any errors. I don't understand. It just suddenly happened today. It didn't have this error the last time I ran D2007. Now when I just closed D2007 and re-opened it and opened the project, the errors are gone. I'm confused about this IDE. Any clarifications appreciated. Edmund
How i can remove the CPU windows in debug mode ?   (280 Views)
Hi Delphi 2007, upd3. When i debug anytime i go n CPU windows. how i can remove for always this windows I want work only in pascal source.
cannot debug on Delphi 6 enterprise   (368 Views)
Hi all, I've copy/pasted a complete directory of y project to make some change in the new code without touching the original. When I try to compile, I don't see the bullets for debugging, so I can't put any break point or anything else. The code runs but I can't debug it...If I change the code I can see the changes in my program, but still can't debug it, my pas seems not to be found by Delphi but it's correctly compiled. What's appening I use Delphi 6 Enterprise.
How can I ignore a mouse click?   (239 Views)
My application executes a third party dll that can take up to 15 seconds to execute and I want to ignore any mouse clicks on a particular control whilst the dll is running. If I set control.enabled to false, then call the dlll, then set enabled back to true after the dll has run any mouse clicks whilst the dll was running execute as soon as I re-eable the control. How can I lose them I have found that if I add a showmessage immediately before setting enabled to true the they do get lost but I do not want the user to see anything. (I have set the cursor to crHourGlass whilst the dll runs)
Error E2161 RLINK32 cannot open DFM file   (307 Views)
OK, this problem is starting to drive me crazy. It never happened to me with Delphi 7, but it is happening all the time with Delphi 2007. The problem is that when I first load my project into Delphi 2007 and then press F9 to compile it, any form that has a tab open in the IDE which contains a Frame object will cause an error: [DCC Error] E2161 Error: RLINK32: Error opening file "CharF.DFM" If I just press F9 again, it will work, but will then give the same error on the *next* form that is open in the editor. Once I have pressed F9 enough times, it will then compile and run the project. Once this happens, it never happens again, until I do a File/Close and reopen the project (or restart Delphi). If I remember to click on each form tab in the IDE and select the Design view to force each form to be displayed, then I do not get any errors. I've seen some old reports in Google about something like this that is apparently hard to reproduce. Unfortunately, my project is huge, so there is no way for me to post it to Quality Central. It's almost like some part of the IDE has the DFM file locked until it is first accessed. This is on Vista Business edition. The files themselves exist and the permissions are all properly set, so I don't think that is the problem. These files are *not* on a network drive...they are on a local drive. When I open the project in Delphi, it doesn't matter how long I wait before hitting F9. I can wait an hour and press F9 and still get the RLINK error the first time. So it's not something in the background that just has the file locked for a short time or anything like that. I have looked in the Vista Monitor tool which lists all of the files currently open by applications on the system, and nobody has these DFM files open. I am also using Castalia, Model Maker Explorer, and GExperts. But I have disabled each of these and that hasn't made any difference either. So I'm stumped. Yes, I can get around the problem by just hitting F9 again, or by remembering to manually open each form in Design mode, but it's getting to be a real annoyance. And the same project in Delphi 7 doesn't have this problem. Any advice is welcome.
Owner drawing, only draw cells that can be seen   (176 Views)
I have a TValueListEditor for which I'm using owner drawing to draw something in each cell. The problem is that when a user resizes the window and my TValueListEditor get smaller scroll bars appear and the user can then scroll. What happens is the owner drawing continues to happen for cells that are off the viewable area, if you scroll down then owner drawing still happens for cells which are off of the viewable space. This causes problems when my program attempts to draw something on the canvas in a location that is off of the screen. How can I limit owner drawing to only draw what the user can actually see, or determine which part of the list editor the user is viewing so that I can only draw on those. - Dan
AV I can't find.   (298 Views)
After leaving ReadDATFile but before returning to mnuUpDateCxClick execution goes off into FastMM4, and bombs with the message 'Access violation at addr 005F84AB in MyApp.exe. Read of addr 00000000.' Madexcept doesn't fire. The AV occurs running in and out of the IDE. Pausing and doing a Find Error on 005F84AB points at the line indicated.
anyone can help? delphi 7 TADOTable cannot connect to 400 columns excel   (525 Views)
I use a TADOConnection (e.g. connection1) to connect a Excel 2007 file with about 400 columns in a worksheet, using the following connectionString: Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\temp\exportFG.xlsx;Extended Properties="Excel 12.0;HDR=YES;" when I set the connected properties to true, no error occur. but when i put a TADOTable and set its connection to connection1, tableDirect = true, only 256 columns can be retrieved!! is this a limitation in Delphi 7 components (I know before Excel 2007, a worksheet has maximum 256 columns only) I am using Delphi 7.
How can I now 2 variables that are referencing TObject descendants refer to the same object   (251 Views)
I have the following old Delphi code I want to change: .... tst, PersonTree : TPersonTree; .... PersonTree.PersonName := PersonDir; //this is a big time consumer! by far from a shallow copy .... tst := PersonTree; // is this a shallow copy .... It seems that ' tst := PersonTree' only copies underlying pointer values. If I put a breakpoint there 'F7' step into, steps over the line to the next statement. But how can I check that. The underlying problem I am trying to solve is that 'PersonTree.PersonName := PersonDir' is far from a shallow copy, it costs 3 seconds. And repeatedly PersonTree retrieves data it had before. So I want to make a list of PersonTree-PersonDir records to cache information already queried, and if the information is already available, I want to let PersonTree refer to a cached item in the list.
IcsDel100.bpl can not be loaded   (484 Views)
Package IcsDel100.bpl cannot be loaded. How serious is this How can it be corrected other than un-installing and re-installing Delphi 2006 Michael
[IQ]How can i get count of textfile lines?   (251 Views)
Hi Consider that i have a big textfile (end of line = CR/LF) How can i count textfile lines i need a fast method.
canvas printing?   (188 Views)
Ok How do you print the canvas to the printer - - I am making an in house app to print labels to a label printer idea is to use a hidden form's canvas and put the text on the canvas and then send that to the printer. I could also use a TImage and print that if it is easier.
[EQ] How can i make a global variable.   (221 Views)
Hi I have 2 programs (consider 2 exe were created by different languages) and want run on one machine. I want pass a value from program1 to program2. There are several ways: 0.Use SendMessage/PostMessage command between main window of the programs ( by their's Handle) 1.Use TCP/IP or any other network protocol between them (IP= 2.Use a constant and fix memory address between them or a variable that both detect and read it's value. 3,... I don't want to use method 0 or 1, i only want use method 2 or any other similar method. Anyone can help me Thank you for your attention H.Ahmadi
how can i change Debug or Release mode?   (254 Views)
Hi in Visual Studio or other compilers IDE we can change building mode to "Release" or "Debug" mode. i dont know where can i change building mode in Borland Studio
can't email attachments (2 methods)   (194 Views)
I'm trying to send an e-mail with an attachment. I want the user to be able to edit the message before sending it. I have tried ShellExecute but the attachment does not go through. I have since read that "mailto:" cannot be used with ShellExecute to send an attachment. I am now trying some code I found, which begins with: var MM, MS : Variant; begin MS := CreateOleObject('MSMAPI.MAPISession'); ... but the CreateOleObject call raises the EOlsSysError exception 'Invalid class string, ProgID: "MSAPI.MAPISession"'. The CodeGear Help seemed to imply that I should register MAPI32.DLL using Run > Register ActiveX Server, but this menu item is disabled in the IDE. What should I try next (N.B. Running Vista Business and Office 2007, with 2007 version of RAD Studio Architect.)
How can one increase the font size of the Object Inspector in D2007?   (457 Views)
Hi! With higher screen resolutions the Object Inspector's font size tends to be too small. Is there a way to change that font size to some higher value The Object Inspector's 'Properties' form does not seem to make that possible.
how can i include version info with delphi exe while building with MSBUILD   (735 Views)
I have able to set the version while building delphi executable by using the D2007 by enabling include version information in project. But i am using MSBUILD to build my .dpr in command prompt. I want to include the version info with MSBUILD
How can I share code or create a static library in Delphi ?   (189 Views)
I have two related projects in my project group (Delphi 10, BDS 2006) that share a number of files, in a tree like this: ProjectGroup - Common - Utils.pas - ZLib.pas - Components.pas - GraphicApp.exe - MainApp.pas - GUI.pas - ConsoleApp.exe - MainConsole.pas - CLI.pas Now GraphicApp and ConsoleApp projects both use files in project Common. I would like Common to be some sort of a library project, library that GraphicApp and ConsoleApp would depend on. Does Delphi have native libraries Or can I set it somehow to output even a C++ like .lib file, and then use it in my other projects But I would still like to have types and forms in my library, and I am afraid this is hard to do with a .lib file I tried to create project Common as a package project, but then it would create a run-time file Common.bpl which works kind of like a ..dll, only in a Borlad - specific format. Meaning it has to stay near the executable, which my clients might not like, or be included in the system's PATH variable. I do not want any dll or dynamic libraries, I only have a number of source files that I want to use in both projects and what I need is a static library or some object files of some kind. Can I create a package like a static library, that would be linked in at compile time Does Delphi have a native static library format Or can I have some kind of project that just compiles the .pas files to .dcu files and then puts them somewhere, where I can use them in the other projects Every kind of project I saw wants to output some sort of executable, different than the .dcu files. Kind regards, Timothy Madden