jpg files

jpg files

Post by Leon Powelso » Fri, 27 Jun 2003 03:52:46



I droped a TImage control into my form.  I am trying to load it via:
  myImage.Picture.LoadFromFile('myPict.jpg');

I get the exception which says jpg files are not valid.  Yet if I go
through the property sheet, I can statically load a jpg file.  I want to
show a blank picture canvis and allow runtime selection of what goes
into it.  How Do I do this?

Thanks
Leon P.

 
 
 

jpg files

Post by Henriqu » Fri, 27 Jun 2003 04:09:30


Hi,

Try this...

MyImage.Picture.Bitmap.LoadFromFile('File.jpg');

[]s

Henrique.


>I droped a TImage control into my form.  I am trying to load it via:
>  myImage.Picture.LoadFromFile('myPict.jpg');

>I get the exception which says jpg files are not valid.  Yet if I go
>through the property sheet, I can statically load a jpg file.  I want to
>show a blank picture canvis and allow runtime selection of what goes
>into it.  How Do I do this?

>Thanks
>Leon P.


 
 
 

jpg files

Post by gc » Fri, 27 Jun 2003 05:42:54


I had the same problem and found this in the newsgroups.  I put it in the
OnCreate of the main form

Image1.Picture.RegisterFileFormat('JPG','JPEG Bitmap',TJPEGIMAGE);

G


Quote:> I droped a TImage control into my form.  I am trying to load it via:
>   myImage.Picture.LoadFromFile('myPict.jpg');

> I get the exception which says jpg files are not valid.  Yet if I go
> through the property sheet, I can statically load a jpg file.  I want to
> show a blank picture canvis and allow runtime selection of what goes
> into it.  How Do I do this?

> Thanks
> Leon P.

 
 
 

jpg files

Post by gc » Fri, 27 Jun 2003 05:47:37


I forgot to mention that it requires

uses jpeg;


Quote:> I droped a TImage control into my form.  I am trying to load it via:
>   myImage.Picture.LoadFromFile('myPict.jpg');

> I get the exception which says jpg files are not valid.  Yet if I go
> through the property sheet, I can statically load a jpg file.  I want to
> show a blank picture canvis and allow runtime selection of what goes
> into it.  How Do I do this?

> Thanks
> Leon P.

 
 
 

jpg files

Post by Leon Powelso » Sat, 28 Jun 2003 02:04:00


Thanks this worked.  With this picture in my TImage control is there a way to
view it as or move it into an TBitmap type object?  I need to use the
"Scanline" function on the bitmap to do low level stuff on it.

Thanks


> I had the same problem and found this in the newsgroups.  I put it in the
> OnCreate of the main form

> Image1.Picture.RegisterFileFormat('JPG','JPEG Bitmap',TJPEGIMAGE);

> G



> > I droped a TImage control into my form.  I am trying to load it via:
> >   myImage.Picture.LoadFromFile('myPict.jpg');

> > I get the exception which says jpg files are not valid.  Yet if I go
> > through the property sheet, I can statically load a jpg file.  I want to
> > show a blank picture canvis and allow runtime selection of what goes
> > into it.  How Do I do this?

> > Thanks
> > Leon P.

 
 
 

jpg files

Post by Danny Thorp » Mon, 30 Jun 2003 07:39:10


Add the jpeg unit to your uses list.  This is done automatically by the IDE
in D5 and later if you open a JPEG image in the TImage control at design
time.  If you don't use any jpg's at design time, you're responsible for
adding the jpeg unit to your project.  (There's no need to register the file
format, the jpeg unit will do that automatically)

-Danny


Quote:> I droped a TImage control into my form.  I am trying to load it via:
>   myImage.Picture.LoadFromFile('myPict.jpg');

> I get the exception which says jpg files are not valid.  Yet if I go
> through the property sheet, I can statically load a jpg file.  I want to
> show a blank picture canvis and allow runtime selection of what goes
> into it.  How Do I do this?

> Thanks
> Leon P.

 
 
 

jpg files

Post by Danny Thorp » Mon, 30 Jun 2003 07:37:19


If you use the jpeg unit, you don't need to register the file format.  The
jpeg unit registers itself automatically.

-Danny


> I forgot to mention that it requires

> uses jpeg;



> > I droped a TImage control into my form.  I am trying to load it via:
> >   myImage.Picture.LoadFromFile('myPict.jpg');

> > I get the exception which says jpg files are not valid.  Yet if I go
> > through the property sheet, I can statically load a jpg file.  I want to
> > show a blank picture canvis and allow runtime selection of what goes
> > into it.  How Do I do this?

> > Thanks
> > Leon P.

 
 
 

jpg files

Post by Danny Thorp » Mon, 30 Jun 2003 07:44:08


Use this:

(MyImage.Picture.Graphic as TJPEGImage).Bitmap;

If you just want to read the pixels of the image, that bitmap will do.  If
you want to modify the pixels using Scanline or other techniques you should
copy that bitmap image to another TBitmap instance
(mybmp.Assign(jpg.Bitmap)).  You can the modify the other TBitmap instance.
The image bits will be shared between the two TBitmap objects until you
modify one of them, and then the modified object creates a copy of the image
automatically.

-Danny


> Thanks this worked.  With this picture in my TImage control is there a way
to
> view it as or move it into an TBitmap type object?  I need to use the
> "Scanline" function on the bitmap to do low level stuff on it.

> Thanks


> > I had the same problem and found this in the newsgroups.  I put it in
the
> > OnCreate of the main form

> > Image1.Picture.RegisterFileFormat('JPG','JPEG Bitmap',TJPEGIMAGE);

> > G



> > > I droped a TImage control into my form.  I am trying to load it via:
> > >   myImage.Picture.LoadFromFile('myPict.jpg');

> > > I get the exception which says jpg files are not valid.  Yet if I go
> > > through the property sheet, I can statically load a jpg file.  I want
to
> > > show a blank picture canvis and allow runtime selection of what goes
> > > into it.  How Do I do this?

> > > Thanks
> > > Leon P.

 
 
 

jpg files

Post by Leon Powelso » Tue, 01 Jul 2003 23:44:53


I tried:
I just want to read(Scan the image) and I do:

  myRow := (image1.Picture.Graphic as TJPEGImage).Bitmap.ScanLine[iRow];

I get a complie error: "undeclared identifier: Bitmap".  What is my error?

Thanks;


> Use this:

> (MyImage.Picture.Graphic as TJPEGImage).Bitmap;

> If you just want to read the pixels of the image, that bitmap will do.  If
> you want to modify the pixels using Scanline or other techniques you should
> copy that bitmap image to another TBitmap instance
> (mybmp.Assign(jpg.Bitmap)).  You can the modify the other TBitmap instance.
> The image bits will be shared between the two TBitmap objects until you
> modify one of them, and then the modified object creates a copy of the image
> automatically.

> -Danny



> > Thanks this worked.  With this picture in my TImage control is there a way
> to
> > view it as or move it into an TBitmap type object?  I need to use the
> > "Scanline" function on the bitmap to do low level stuff on it.

> > Thanks


> > > I had the same problem and found this in the newsgroups.  I put it in
> the
> > > OnCreate of the main form

> > > Image1.Picture.RegisterFileFormat('JPG','JPEG Bitmap',TJPEGIMAGE);

> > > G



> > > > I droped a TImage control into my form.  I am trying to load it via:
> > > >   myImage.Picture.LoadFromFile('myPict.jpg');

> > > > I get the exception which says jpg files are not valid.  Yet if I go
> > > > through the property sheet, I can statically load a jpg file.  I want
> to
> > > > show a blank picture canvis and allow runtime selection of what goes
> > > > into it.  How Do I do this?

> > > > Thanks
> > > > Leon P.

 
 
 

jpg files

Post by Graham Mur » Wed, 02 Jul 2003 00:20:40


I'm don't think that it's possible to do it this way, TJpegImage doesn't
have a bitmap property...

The only way I have found t owork with JPegs in the past is to first copy
them to a bitmap so that the ScanLine can be accessed...

function JpegToBitmap(AJpeg: TJpegImage): TBitmap;
begin
  Result := TBitmap.Create;
  Result.Assign(AJpeg);
end;

Hope this helps

Graham

--
GmPrintSuite Print & Print Preview Components
http://www.murtsoft.co.uk/


> I tried:
> I just want to read(Scan the image) and I do:

>   myRow := (image1.Picture.Graphic as TJPEGImage).Bitmap.ScanLine[iRow];

> I get a complie error: "undeclared identifier: Bitmap".  What is my error?

> Thanks;


> > Use this:

> > (MyImage.Picture.Graphic as TJPEGImage).Bitmap;

> > If you just want to read the pixels of the image, that bitmap will do.
If
> > you want to modify the pixels using Scanline or other techniques you
should
> > copy that bitmap image to another TBitmap instance
> > (mybmp.Assign(jpg.Bitmap)).  You can the modify the other TBitmap
instance.
> > The image bits will be shared between the two TBitmap objects until you
> > modify one of them, and then the modified object creates a copy of the
image
> > automatically.

> > -Danny



> > > Thanks this worked.  With this picture in my TImage control is there a
way
> > to
> > > view it as or move it into an TBitmap type object?  I need to use the
> > > "Scanline" function on the bitmap to do low level stuff on it.

> > > Thanks


> > > > I had the same problem and found this in the newsgroups.  I put it
in
> > the
> > > > OnCreate of the main form

> > > > Image1.Picture.RegisterFileFormat('JPG','JPEG Bitmap',TJPEGIMAGE);

> > > > G



> > > > > I droped a TImage control into my form.  I am trying to load it
via:
> > > > >   myImage.Picture.LoadFromFile('myPict.jpg');

> > > > > I get the exception which says jpg files are not valid.  Yet if I
go
> > > > > through the property sheet, I can statically load a jpg file.  I
want
> > to
> > > > > show a blank picture canvis and allow runtime selection of what
goes
> > > > > into it.  How Do I do this?

> > > > > Thanks
> > > > > Leon P.

 
 
 

jpg files

Post by Danny Thorp » Wed, 02 Jul 2003 08:02:37


Woops!  Sorry.  Use the assign technique Graham mentioned.

I forgot that I made the Bitmap property protected in TJPEGImage.  It's
protected because I couldn't guarantee read-only behavior on the bitmap, and
you definitely don't want to be drawing on a JPEG.

-Danny


> I tried:
> I just want to read(Scan the image) and I do:

>   myRow := (image1.Picture.Graphic as TJPEGImage).Bitmap.ScanLine[iRow];

> I get a complie error: "undeclared identifier: Bitmap".  What is my error?

> Thanks;


> > Use this:

> > (MyImage.Picture.Graphic as TJPEGImage).Bitmap;

> > If you just want to read the pixels of the image, that bitmap will do.
If
> > you want to modify the pixels using Scanline or other techniques you
should
> > copy that bitmap image to another TBitmap instance
> > (mybmp.Assign(jpg.Bitmap)).  You can the modify the other TBitmap
instance.
> > The image bits will be shared between the two TBitmap objects until you
> > modify one of them, and then the modified object creates a copy of the
image
> > automatically.

> > -Danny



> > > Thanks this worked.  With this picture in my TImage control is there a
way
> > to
> > > view it as or move it into an TBitmap type object?  I need to use the
> > > "Scanline" function on the bitmap to do low level stuff on it.

> > > Thanks


> > > > I had the same problem and found this in the newsgroups.  I put it
in
> > the
> > > > OnCreate of the main form

> > > > Image1.Picture.RegisterFileFormat('JPG','JPEG Bitmap',TJPEGIMAGE);

> > > > G



> > > > > I droped a TImage control into my form.  I am trying to load it
via:
> > > > >   myImage.Picture.LoadFromFile('myPict.jpg');

> > > > > I get the exception which says jpg files are not valid.  Yet if I
go
> > > > > through the property sheet, I can statically load a jpg file.  I
want
> > to
> > > > > show a blank picture canvis and allow runtime selection of what
goes
> > > > > into it.  How Do I do this?

> > > > > Thanks
> > > > > Leon P.