Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2002-09

TImage not displaying image?

11 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tony Maro
to Andrew Johnson: If you don't have this button, your Lazarus is older than yesterday, because the property…

Okay, I grabbed the CVS just now and rebuilt. The editor is there and it displays fine during editing. Now, I launch my program with the TImage on the form and have a button to load from file and as soon as it does, it crashes.

Here's the code:

image1.picture.loadfromfile('/home/tonym/rdphead.bmp');

The bitmap was originally true color. After that crashed I reduced it to 128 colors indexed and RGB both to no avail. Here's what happens in the console window when the app is run and this line is called:

Form Stream "TFORM1" Signature=TPF0
TPicture.LoadFromFile A TBITMAP
TPicture.LoadFromFile B TBITMAP
TPicture.LoadFromFile C
TPicture.LoadFromFile D
TPicture.LoadFromFile E
TPicture.LoadFromFile F
An unhandled exception occurred at 0x080E7BE9 :
Access violation
0x080E7BE9 main, line 12 of extctrls.pp
0x080DB3CB
0xBFFFE50C main, line 14 of gtkint.ppgtkproc.inc An unhandled exception occurred at 0x080D504A :
Access violation
0x080D504A

forms.pp - finalization section
[TgtkObject.Destroy] WARNING: There are 9 unreleased GDIObjects, a detailed dump follows:
[TgtkObject.Destroy] GDIOs: 08110904 08110894 08110844 081107D4 08110764 081106F4 08110684
[TgtkObject.Destroy] gdiBrush: 6
[TgtkObject.Destroy] gdiPen: 3

I know everything's not finished yet with lazarus (and probably never will be :-) so I apologize if I'm asking a stoopid question about a feature that just doesn't work yet, but Andrew stated I should be able to load the image at runtime... Transparency and Autosize are both turned off.

Andrew Johnson wrote 21 lines
>there's no ellipsis button If you don't have this button, your Lazarus is older than yesterday, because the property editor wasn't added until yesterday morning, along with the fixes which make TImage work. Even so, please note that changing the image in Lazarus will not change it in the program yet, as TBitmap/TPixmap cannot save to streams yet. However, after updating your lazarus from CVS, you should be able to load the image at runtime. Though there are problems with Transparency and AutoSize not always working yet. I am still tryig to figure out why.. Andrew _________________________________________________________________ Join the world�s largest e-mail service with MSN Hotmail. http://www.hotmail.com _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives

Reply by email

Andrew Johnson
there's no ellipsis button

If you don't have this button, your Lazarus is older than yesterday, because the property editor wasn't added until yesterday morning, along with the fixes which make TImage work.

Even so, please note that changing the image in Lazarus will not change it in the program yet, as TBitmap/TPixmap cannot save to streams yet. However, after updating your lazarus from CVS, you should be able to load the image at runtime. Though there are problems with Transparency and AutoSize not always working yet. I am still tryig to figure out why..

Andrew

_________________________________________________________________ Join the world�s largest e-mail service with MSN Hotmail. http://www.hotmail.com

Reply by email

Andrew Johnson
Show quoted text 5 lines
mybitmap := TBitmap.Create; mybitmap.loadfromfile('test.bmp'); image1.Picture.Bitmap := mybitmap; Would something along these lines be valid, or do I use the ASSIGN method?

Yes this should work, but Assign would not.. TBitmap.Assign has not been implemented yet for various reason.. Also because Assign does not work the TPicture actually uses
the Bitmap passed, not just a copy of it, therefore you should not free it when done.. as this will cause an AV in TPicture.

Andrew

_________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply by email

Andrew Johnson
Image1.picture.loadfromfile('/home/tony/test.bmp'); In design mode, I can choose the same image and it displays it just fine.

Then I really don't get it. The Property Editor runs the Exact same routine, that is, Picture.LoadFromFile.
I just did the exact same thing as you, without problem. All worked as expected. Sorry I can't help you more, but this is beyond my ken. Until I can reproduce the error, I can't trace it, nor fix it.

I am running Lazarus on two different machines (work and home) and BOTH do the same thing. Of course >both are Mandrake 8.2 and updated with red-carpet... could be a package in there conflicting?

its possible, but I do not know. I am using Red-Hat 7.3 W/Red-Carpet without issue. And while I haven't tested image code on any Mandrake system, since they are both using Ximian, they should have the same versions of the important packages installed, aka glib, gtk, gdk-pixbuf.

The crash of the above test complained about line 12 of extctrls.pp and line 14 of gtkint.ppgtkproc.inc ???

line 12... is a part of the file header.. nothing there. the other is just the button callback handler I believe.

Andrew

_________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx

Reply by email

Michael A. Hess
to Andrew Johnson
Andrew Johnson wrote 11 lines
On Wed, 4 Sep 2002 22:56:08 -0500 "Tony Maro" wrote: > Image1.picture.loadfromfile('/home/tony/test.bmp'); > In design mode, I can choose the same image and it displays it just fine. Then I really don't get it. The Property Editor runs the Exact same routine, that is, Picture.LoadFromFile. I just did the exact same thing as you, without problem. All worked as expected. Sorry I can't help you more, but this is beyond my ken. Until I can reproduce the error, I can't trace it, nor fix it.

Tony, could you zip up the .lfm, .pas, .prj, plus the image, etc that you are trying to use and send it to Andrew. That way he can try EXACTLY the same thing you are trying. If he still doesn't get the error then we know it is something with the setup of your machine and not some quirk with the image or coding. (Send an email directly to Andrew with the stuff attached. Don't send it to the list)

==== Programming my first best destiny! ==== Michael A. Hess Miracle Concepts, Inc. http://www.miraclec.com

Reply by email

Tony Maro
to Andrew Johnson: On Wed, 4 Sep 2002 22:56:08 -0500 Then I really don't get it. The Property Editor runs…
Michael A. Hess wrote 8 lines
Tony, could you zip up the .lfm, .pas, .prj, plus the image, etc that you are trying to use and send it to Andrew. That way he can try EXACTLY the same thing you are trying. If he still doesn't get the error then we know it is something with the setup of your machine and not some quirk with the image or coding. (Send an email directly to Andrew with the stuff attached. Don't send it to the list)

I did one better. It's posted at http://tony.maro.net/testcrash.tar.gz for anyone who's interested in trying it. Maybe I'm about to stick my foot in my mouth by posting a really stooooopid user error... and now I've posted it to this list for all to flame me over ;-) I hope so because at least then someone can tell me how to make it work!

The gzip's about 860k and includes the compiled application as well just to see if anyone gets that to work without recompiling it themselves.

Thanks,

Tony Maro

Reply by email

Tony Maro
to Andrew Johnson: On Wed, 4 Sep 2002 22:56:08 -0500 Then I really don't get it. The Property Editor runs…
Michael A. Hess wrote 6 lines
> I did one better. It's posted at http://tony.maro.net/testcrash.tar.gz > for anyone who's interested in trying it. Tried it. Didn't work for me either. :-)

Andrew found that my compiled app didn't work, but when he recompiled my source with no changes, it did. His compiled app worked on my PC so (as per Andrew's suggestion) it's something in the compiler / linker on my end? Perhaps it only works on Andrew's computer and HE'S the problem! LOL (just kidding)

I've since removed my install of FPC from the ELF.tar and reinstalled using the RPM's. I still can't compile the app and make it work. Same crash.

Any other ideas out there? My apps will be rather boring without graphics in them...

On a side note, I found that I can create a TBitmap and use the loadfromfile method for it without a crash, but when I try the loadfromfile method of the TIMAGE it fails every time. Perhaps something in the interpretation of the file type is amiss with a unit on my PC's?

I'm a little rusty... can someone give me an example of assigning a TBitmap to a TIMAGE once I've loaded it into the TBitmap?

i.e.

mybitmap := TBitmap.Create;
mybitmap.loadfromfile('test.bmp');
image1.Picture.Bitmap := mybitmap;

Would something along these lines be valid, or do I use the ASSIGN method?

Thanks,
Tony

Reply by email

Andrew Johnson
Form Stream "TFORM1" Signature=TPF0

I am unclear... did this exception occure immediatly on starting the program, or on button click? If it happens on program Load its probably because of the unfinished saving, though with the improvements that should no longer be happening either. But in any case I am unable to get any error like this.. I have tried and tried! Have you tried other Images? I would suggest first try loading the image with the Property Editor and see if it kills Lazarus. If not try a different Image file in your code, preferably an .xpm file. Also, make sure your gdkpixbuf library is version 0.16.0 or greater. This can be checked from the command line:

gdk-pixbuf-config --version

Otherwise, I am completely clueless.. even disabling GDKPixbuf support doesn't cause this error.

Sorry.

Andrew

_________________________________________________________________ Join the world�s largest e-mail service with MSN Hotmail. http://www.hotmail.com

Reply by email

Tony Maro
to Andrew Johnson: On 05 Sep 2002 10:44:43 -0400 Yes this should work, but Assign would not.. TBitmap.Assign…

Well I'll be a monkey's uncle...

Here's what I did:

Installed from the ELF.tar
TIMAGE failed.
Removed everything I could find and installed the RPM's TIMAGE failed.
Removed the RPM's for FPC.
Deleted all references I could find.
Downloaded the CVS edition of FPC and realized I was clueless about making that work so did nothing with it.
Reinstalled from the ELF.tar (AGAIN)

Now my app works with the TIMAGE.
WTF? I know the CVS portion above is unrelated, because I never did anything with it once I downloaded it.

That's just plain WEIRD.

Reply by email

Tony Maro
Andrew Johnson wrote
>I am unclear... did this exception occure immediatly on starting the

program, or on button click?

Okay... I checked the pixbuf version and it's 0.18.0. I'm running Mandrake 8.2 with Gnome and keep my packages updated with Ximian's red-carpet.

I've got today's CVS of Lazarus. I've got FPC 1.0.6.

I created a new "Application" project.

I dropped a TIMAGE on the form. No graphic loaded into it yet...

I dropped a TButton on the form.

I added the following code to TButton's onclick:
Image1.picture.loadfromfile('/home/tony/test.bmp');

Compile and run the app... click the button and BOOM - it dies.

In design mode, I can choose the same image and it displays it just fine.

I am running Lazarus on two different machines (work and home) and BOTH do the same thing. Of course both are Mandrake 8.2 and updated with red-carpet... could be a package in there conflicting?

The crash of the above test complained about line 12 of extctrls.pp and line 14 of gtkint.ppgtkproc.inc ???

<<winmail.dat>>

Reply by email