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
Solved

Displaying Jpeg images in a form

Posted on 1998-11-22
3
296 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
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

829 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