Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Displaying Jpeg images in a form

Posted on 1998-11-22
3
Medium Priority
?
316 Views
Last Modified: 2013-11-19
Good day all,

Could someone put up a code fragment for grabbing and displaying a jpeg on a form? The reference to where the file is could be a field in a database, or a BLOB. (Well, actually, those are the same things.) I'm pretty much just looking to display some jpegs on a form, though.

I'll be poking around Tjpeg this evening...

Oneeye
0
Comment
Question by:oneeye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 total points
ID: 1347620
Place a TJPEGImage component on your form. Put a jpeg image in it like this:

MyJPEGImage.LoadFromFile('MyJpeg.jpg');

or

MyJPEGImage.LoadFromStream(TFileStream.Create('MyJPEG.jpg', rmOpenRead)).

The latter one can be used with a TMemoryStream if you want to read the JPEG out of a BLOB...

Cheers,

Raymond.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347621
I don't have that component... I have Delphi 3 and use this:


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,JPEG;

type
  TForm1 = class(TForm)
    procedure FormClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}



procedure TForm1.FormClick(Sender: TObject);
var JPG: TjpegImage;
begin
if FileExists('c:\a.jpg') then begin
    JPG := TJpegImage.Create;
    try
      JPG.LoadFromFile('c:\a.jpg');
      Canvas.Draw(0,0, JPG);
    finally
      JPG.Free;
    end;
end;
end;

end.




try this, ( you have to double click on the OnClick event of the form on the object inspector ).

then run it, click on the form, and there you have it !


bryan


0
 

Author Comment

by:oneeye
ID: 1347622
Ah, thanks both of you. In combination with the example in the delphi help, that gives me a pretty good handle on it...

Oneeye
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In this second Micro Tutorial in the series,  viewers will learn more basic shortcuts and functions of Illustrator. In this tutorial you will learn about the eyedropper tool, zoom , ellipses and more.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question