?
Solved

Delphi 3 and GIF/JPEG support in TImage

Posted on 2003-03-28
5
Medium Priority
?
808 Views
Last Modified: 2013-11-19
I am using Delphi 3 Pro.  I am trying to add a JPEG or GIF image to my project's form.  I came across a note somewhere that there is a JPEG.DCU on the installation CD in the \extras folder.  I found the unit, and placed it in the Delphi \bin folder, and added JPEG to my "uses" line, however, whenever I place a TImage on my form, and double click on the component, the Picture Editor dialog does not list "JPEG" as a supported file type.

How do you add a JPEG image to a Delphi 3 form?

Likewise, a GIF?
0
Comment
Question by:Kapusta
[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
  • 4
5 Comments
 
LVL 3

Accepted Solution

by:
tongalite earned 400 total points
ID: 8230885
Hi,
To load Gifs you'll need to install a Gif control. One of the best is from Sulako (do a Google search or leave an e-mail address and I'll mail you the comp. I use only that comp in D3 Pro)

To load a JPEG image do this:
***************
procedure TForm1.Button1Click(Sender: TObject);

var
    jpg: TJPEGImage; // TJPEGImage object to load my jpeg into
begin
    jpg := TJPEGImage.Create;
    jpg.LoadFromFile('C:\Windows\Desktop\race.jpg');  
//Adjust the path to your Jpeg image

    Image1.Picture.Assign(jpg); // Now assign the jpeg to the TImage's

    jpg.Free;  // TJPEGImage object has outlived its usefulness

end;
*****************
hope this helps :-)
Good luck
T.

0
 
LVL 3

Expert Comment

by:tongalite
ID: 8231972
Forgot to mention...

JPEG in USES clause.
T.
0
 

Author Comment

by:Kapusta
ID: 8232161
>> JPEG in USES clause.

But that does not change the "File type" filter list for the Picture Editor when you double click on a TImage component.  JPEGs aren't permitted to be loaded via this method (Picture Editor).
0
 
LVL 3

Expert Comment

by:tongalite
ID: 8232603
Hi,
That's correct you cannot load them with the picture editor. You must load them from file. Alternatively you can compile the jpeg image into a resource file and stream the image from the resource file. This means the image is embedded into your exe and so therefore no dependance on any external files.

T.
0
 
LVL 3

Expert Comment

by:tongalite
ID: 8232651
Why don't you use an OpenPictureDialog?
You can set the filter to open jpegs in the filter editor. Add this in the editor:
//in the left column type  =      JPEG (*.jpg)
//in the right column type =     *.jpg

here is a sample unit to display the images;
//add a Timage. a Tbutton and TOpenPictureDialog (pd1)

*******************
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, ExtCtrls,Jpeg,ExtDlgs;
type
  TForm1 = class(TForm)
    pd1: TOpenPictureDialog;
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);

begin

 if PD1.Execute then
begin
// Load the selected image
   Image1.Picture.LoadFromFile(
                  pd1.FileName );

   end;
    end;
     end.
**************************
That's about all I can suggest.
T.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Learn how to set up basic frames and paths in Prezi and understand the open space that Prezi allows you to create presentations in.
Not only does Prezi allow you to create non-linear presentations, it also makes it easy to apply transition animations between your frames. Learn how to apply a fade-in transition to select items and entire frames in this tutorial Select "Edit Path"…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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