How to show images ?

Linux specific forum
Mowen
User
User
Posts: 48
Joined: Tue Oct 07, 2003 1:04 pm
Location: Belgium

How to show images ?

Post by Mowen »

Hi all,

I use PB 3.92 for Linux and I try to show images in a window. But nothing appears. I tried with DrawImage (apparently supported now) and also with an ImageGadget but both methods not work. How can we do :?: It works fine on the Windows version.
PureBasic: one of the best programming tools ever ! PB is light, easy, crossplatform, powerfull, fast, extendable, enjoyable and... tasty ;-)
olejr
Enthusiast
Enthusiast
Posts: 152
Joined: Sun Jul 11, 2004 7:48 pm
Location: Lillehammer, No(r)way
Contact:

Post by olejr »

I had some problems with images too...
Had the desktop set to 16bit,
changed to 24 or 32 bit and it worked...

But this was with v3.91.. Don't know if that's changed..
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Could you post a little snippet ?
olejr
Enthusiast
Enthusiast
Posts: 152
Joined: Sun Jul 11, 2004 7:48 pm
Location: Lillehammer, No(r)way
Contact:

Post by olejr »

@Fred: sure.. :wink:

Code: Select all

LoadImage(1,"logo.bmp") ; renamed PB logo

OpenWindow(0,0,0,200,187,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Linux Image Gadget")
  CreateGadgetList(WindowID())
  ImageGadget(0,0,0,200,187,UseImage(1))

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
When you try to run it on desktop < 24bit.. It gives:
Gdk-ERROR ** : BadMatch (invalid parameter attributes) serial 52 error_code 8 request_code 147 minor_code 3
Gdk-ERROR ** : BadMatch (invalid parameter attributes) serial 53 error_code 8 request_code 147 minor_code 3

And the first time i came over this, i did report it in the bug section.. :wink:
viewtopic.php?t=11727&highlight=
Mowen
User
User
Posts: 48
Joined: Tue Oct 07, 2003 1:04 pm
Location: Belgium

Post by Mowen »

I give another sample with jpeg and SetGadgetState. I am in 24bits color too and I do not get any error messages. Just a blank window without image.

Code: Select all

Enumeration
  #frmMain
  #imgMain
EndEnumeration

UseJPEGImageDecoder()

OpenWindow(#frmMain, 50, 50, 500, 450, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered, "ImageViewer")
CreateGadgetList(WindowID(#frmMain))
ImageGadget(#imgMain, 0, 0, 500, 450, 0)
If LoadImage(1, "test.jpg")
  SetGadgetState(#imgMain, UseImage(1))
Else
  MessageRequester("Error", "Cannot load the image !")
EndIf

Repeat
  EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
End
PureBasic: one of the best programming tools ever ! PB is light, easy, crossplatform, powerfull, fast, extendable, enjoyable and... tasty ;-)
Mowen
User
User
Posts: 48
Joined: Tue Oct 07, 2003 1:04 pm
Location: Belgium

Post by Mowen »

Any news about this, Fred ? We know you are working on the Windows version for now but can we expect to be solved soon if it is not a major bug ? It is blocking issue on the project I am working on. :(
PureBasic: one of the best programming tools ever ! PB is light, easy, crossplatform, powerfull, fast, extendable, enjoyable and... tasty ;-)
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Yes, I will take a look to it quickly.
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

In fact it's because the imagegadget() is created with a null ImageID. If you pass the imageID directly, it should work (little workaround until it's fixed).
Mowen
User
User
Posts: 48
Joined: Tue Oct 07, 2003 1:04 pm
Location: Belgium

Post by Mowen »

Thanks Fred to take a look at it.

In fact I have the same issue when directly using the ImageId as shown in the olejr's code sample.
PureBasic: one of the best programming tools ever ! PB is light, easy, crossplatform, powerfull, fast, extendable, enjoyable and... tasty ;-)
Mowen
User
User
Posts: 48
Joined: Tue Oct 07, 2003 1:04 pm
Location: Belgium

Post by Mowen »

Hi Fred,

I tried the new libraries (Image and Gadget) available in beta/linux. The direct image allocation in the ImageGadget() function works now. Thanks for it. 8) But it does not work yet when you try to set another image by using the SetGadgetState() function. It would be nice if you could solve it too.
PureBasic: one of the best programming tools ever ! PB is light, easy, crossplatform, powerfull, fast, extendable, enjoyable and... tasty ;-)
bender-rulez
User
User
Posts: 49
Joined: Mon Mar 14, 2005 11:30 am

Post by bender-rulez »

Hi,

I tested the linux/beta libs and get some errors when I try to display ImageGadget or ButtonImageGadget

Code: Select all

(<unknown>:1892): Gdk-WARNING **: The gdk_draw_*_image require the drawable argument to
have a specified colormap. All windows have a colormap,
however, pixmaps only have colormap by default if they
were created with a non-NULL window argument. Otherwise
a colormap must be set on them with gdk_drawable_set_colormap

(<unknown>:1892): Gdk-WARNING **: Attempt to draw a drawable with depth 32 to a drawable with depth 24
my display is 24 bit cause the 16 bit bug, but now it seems it should be 32 bit???

the image is an indexed (256 color) bmp!

I´m using the -s gtk2 switch for compiling
bender-rulez
User
User
Posts: 49
Joined: Mon Mar 14, 2005 11:30 am

Post by bender-rulez »

the image example from purebasic does the same error!

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Image example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;

If OpenWindow(0, 100, 100, 300, 300, #PB_Window_SystemMenu, "PureBasic - Image")

  Gosub CreateImage

  CreateGadgetList(WindowID())
    ImageGadget(0, 10, 10, 100, 100, ImageID())

  Repeat
    EventID = WaitWindowEvent()
  Until EventID = #PB_EventCloseWindow  ; If the user has pressed on the close button
  
EndIf

End   ; All the opened windows are closed automatically by PureBasic


;
; Some 2D graphics functions...
;

CreateImage:

  If CreateImage(0, 255, 255)
    If StartDrawing(ImageOutput())
        
      For k=0 To 255
        FrontColor(k,0, k)  ; a rainbow, from black to pink
        Line(0, k, 255, 0)
      Next

      DrawingMode(1)
      Locate(40, 50)
      FrontColor(255,255,255) ; print the text to white !
      DrawText("An image created easely...")

      StopDrawing() ; This is absolutely needed when the drawing operations are finished !!! Never forget it !
      
    EndIf  
  EndIf

Return

Code: Select all

(<unknown>:1952): Gdk-WARNING **: Attempt to draw a drawable with depth 32 to a drawable with depth 24
count = 1

Any hint?
olejr
Enthusiast
Enthusiast
Posts: 152
Joined: Sun Jul 11, 2004 7:48 pm
Location: Lillehammer, No(r)way
Contact:

Post by olejr »

Works here with 24bit display..
Oh.. And all the betalibs installed..
bender-rulez
User
User
Posts: 49
Joined: Mon Mar 14, 2005 11:30 am

Post by bender-rulez »

ok, I found it, it´s the 'image' lib (gtk2) with the one from 3.92 it works under 24 bit without error message!

but I think it should even be fixed for 16 bit mode!
Post Reply