Solved

Displaying Jpeg images in a form

Posted on 1998-11-22
3
272 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
3 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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.
Learn the basics of inputting and editing your text components in Prezi. We will cover how to set styles, position, and group your text components. In your Prezi editor, click anywhere on the canvas to add text: A flashing cursor informs you that yo…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now