Solved

Displaying Jpeg images in a form

Posted on 1998-11-22
3
312 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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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…
Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
Learn how to create interesting presentations by including videos to keep your audience engaged using Prezi. Select "Insert" from the top menu in your Prezi editor: Select "YouTube Video": Paste the video URL into the prompt: "Select "Insert":…
Suggested Courses

627 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