Board index » delphi » Trouble with TPicture.Bitmap.Handle...

Trouble with TPicture.Bitmap.Handle...

Hi all,

I'm facing the problem that every time I load an image file that was not
originally a "bmp" file i.e a "jpg" in TPicture and I pass the
Picture.bitmap.handle to another function it is 0 (zero!!!) and I can't
access the bitmap anymore. On the other side I have absolutely no problem If
a bmp file is loaded...

Any ideas....???

Tanks Niko

 

Re:Trouble with TPicture.Bitmap.Handle...


uses Jpeg;

^_^

Quote
"Niko Rebenich" <Niko.Reben...@t-online.de> wrote in message

news:3ced465a_1@dnews...
Quote
> Hi all,

> I'm facing the problem that every time I load an image file that was not
> originally a "bmp" file i.e a "jpg" in TPicture and I pass the
> Picture.bitmap.handle to another function it is 0 (zero!!!) and I can't
> access the bitmap anymore. On the other side I have absolutely no problem
If
> a bmp file is loaded...

> Any ideas....???

> Tanks Niko

Re:Trouble with TPicture.Bitmap.Handle...


"Niko Rebenich" <Niko.Reben...@t-online.de> skrev i en meddelelse
news:3ced465a_1@dnews...

Quote
> I'm facing the problem that every time I load an image file that was not
> originally a "bmp" file i.e a "jpg" in TPicture and I pass the
> Picture.bitmap.handle to another function it is 0 (zero!!!) and I can't
> access the bitmap anymore. On the other side I have absolutely no problem
If
> a bmp file is loaded...

When you load an image file which is not a "bmp" into a TPicture then it
does not contain a bitmap.
Therefore Picture.Bitmap and Picture.Bitmap.Handle is not valid and should
not be used.
--
Finn Tolderlund

Re:Trouble with TPicture.Bitmap.Handle...


Quote
---- Original Message -----
From: "Finn Tolderlund"
> When you load an image file which is not a "bmp" into a TPicture then it
> does not contain a bitmap.
> Therefore Picture.Bitmap and Picture.Bitmap.Handle is not valid and should
> not be used.
> --
> Finn Tolderlund

Yes, that was it...
I was thinking the jpeg would also be stored as bitmap in TPicture... but
this was WRONG it is placed in TGraphic...
But because I need a Bitmap (or DIB) with handle I probably have to convert
TGraphic in a Bitmap using Bitmap.Canvas.Draw(0,0,Graphic).
Or do you have any other ideas...???

Thanks a lot for your Replies

Niko Renenich

Re:Trouble with TPicture.Bitmap.Handle...


"Niko Rebenich" <Niko.Reben...@t-online.de> skrev i en meddelelse
news:3cf0cd6d$1_2@dnews...

Quote
> But because I need a Bitmap (or DIB) with handle I probably have to
convert
> TGraphic in a Bitmap using Bitmap.Canvas.Draw(0,0,Graphic).

That's what you will have to do.
--
Finn Tolderlund

Re:Trouble with TPicture.Bitmap.Handle...


You should first assign the picture to a bitmap and then
you can use that handle.

Try this
========
myPicture := TPicture.Create;
myBitmap := TBitmap.Create
myPicture.LoadFromFile('SomePicture.JPG');
myBitmap.Assign(myPicture.Graphic);
// or use:
// mBitmap.Canvas.Draw(0,0,mPicture.Graphic);
// if it is an ICO or EMF or WMF
myPicture.Free;
..
// now you can use myBitmap.Handle
// don't forget to free the bitmap after you used it.
// or do the following:
Form1.Image1.Picture.Bitmap.Assign(myBitmap);
myBitmap.Free;
// now you can use: h := Form1.Image1.Picture.Bitmap.Handle;

Quote
"morhming" <woshishei...@cnnb.net> wrote:
>uses Jpeg;

>^_^

>"Niko Rebenich" <Niko.Reben...@t-online.de> wrote in message
>news:3ced465a_1@dnews...
>> Hi all,

>> I'm facing the problem that every time I load an image file that was not
>> originally a "bmp" file i.e a "jpg" in TPicture and I pass the
>> Picture.bitmap.handle to another function it is 0 (zero!!!) and I can't
>> access the bitmap anymore. On the other side I have absolutely no problem
>If
>> a bmp file is loaded...

>> Any ideas....???

>> Tanks Niko

Re:Trouble with TPicture.Bitmap.Handle...


"M. de Haan"

Quote
> You should first assign the picture to a bitmap and then
> you can use that handle.

> Try this
> ========
> myPicture := TPicture.Create;
> myBitmap := TBitmap.Create
> myPicture.LoadFromFile('SomePicture.JPG');
> myBitmap.Assign(myPicture.Graphic);
> // or use:
> // mBitmap.Canvas.Draw(0,0,mPicture.Graphic);
> // if it is an ICO or EMF or WMF
> myPicture.Free;
> ..
> // now you can use myBitmap.Handle
> // don't forget to free the bitmap after you used it.
> // or do the following:
> Form1.Image1.Picture.Bitmap.Assign(myBitmap);
> myBitmap.Free;
> // now you can use: h := Form1.Image1.Picture.Bitmap.Handle;

Many thanks to you...

Niko

Other Threads