Display image in Linux

Linux specific forum
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Display image in Linux

Post by Beach »

Can someone share an example of how to display a graphic image when using the linux compiler? I have tried different things but have not been successful. Thanks!

-Beach
User avatar
Brujah
Enthusiast
Enthusiast
Posts: 237
Joined: Mon Nov 03, 2003 7:45 pm
Location: Germany
Contact:

Post by Brujah »

Display it as a sprite.
Thats an easy way.
Christian
Enthusiast
Enthusiast
Posts: 154
Joined: Mon Dec 08, 2003 7:50 pm
Location: Germany

Post by Christian »

ImageGadget should also work, if you work without a screen. Or use the DrawImage()-function.

If you use PB under Windows as well then handle the graphic thing under Linux like you do it under Windows. ;)

regards,
Christian
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

I still am unable to get a image to work on Linux PB projects, it must be something I am doing wrong... I am using Windows to write and test the code but it will not compile on Linux. Here is the code:

Code: Select all

Enumeration 1
  #Window_Form1
  #image
  #exit
EndEnumeration

FileName$ = "logo.bmp"
LoadImage(#image, FileName$)

Procedure.l Window_Form1()
  If OpenWindow(#Window_Form1,175,0,268,187,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible,"Linux Text")
    If CreateGadgetList(WindowID(#Window_Form1))
      ButtonGadget(#exit,105,145,60,20,"Exit")
      HideWindow(#Window_Form1,0)
      ProcedureReturn WindowID()
    EndIf
  EndIf
EndProcedure

If Window_Form1()
  
  StartDrawing(WindowOutput())
    imgid = UseImage(#image)
    DrawImage(imgid,10,50,48,48)
  StopDrawing()  
  
  quitForm1=0
  Repeat
    EventID=WaitWindowEvent()
    Select EventID
      Case #PB_Event_CloseWindow
        If EventWindowID()=#Window_Form1
          quitForm1=1
        EndIf

      Case #PB_Event_Gadget
        Select EventGadgetID()
          Case #exit
            End
            
        EndSelect
    EndSelect
  Until quitForm1
  CloseWindow(#Window_Form1)
EndIf
End
And the error when attemping to compile on Linux:
******************************************
PureBasic Linux x86 v3.81
******************************************

Loading external modules...
Starting compilation...
48 lines processed.
Creating the executable.
purebasic.o(.text+0x13f): In function `main':
: undefined reference to `PB_DrawImage2'
collect2: ld returned 1 exit status

- Feel the ..PuRe.. Power -
Is there an obvious syntax error? If it helps, "logo.bmp" has 256 colors and I am using RedHat 9

-Beach
robink
User
User
Posts: 26
Joined: Sat Jan 03, 2004 7:25 pm
Location: Rinteln
Contact:

Post by robink »

That is a PB bug, DrawImage(ImageID, x, y , [NewWidth, NewHeight])
with NewWidth and NewHeight isn't working.
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

Thanks for the reply. Does this mean you can not add image graphics if you are using the LInux version? If so, what is the correct way. I just want to add a image to my form.

-Beach
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

I changed the line:

Code: Select all

DrawImage(imgid,10,50,48,48)
to

Code: Select all

DrawImage(imgid,10,50)
and now it compiles, however, when I execute the app is receive this error:

Gdk-ERROR **: BadMatch (invalid parameter attributes)
serial 51 error_code 8 request_code 146 minor_code 3

Any ideas?

-Beach
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

I am still trying to get an image to display on my window when compiling on Linux. I have changeded distro's (Mandrake 10) since this was first posted and loaded the new version of PB (3.91) but I still do not get an image. There are no errors when compling the code - but I receieve this error on the command line when I execute the app: "DrawImage GTK not implemented"

I have both GTK 1.2 dev and SDL 1.2 dev loaded, am I missing something else?

Code: Select all

UseJPEGImageDecoder()
FileName$ = "logo.jpg"
LoadImage(1, FileName$)

OpenWindow(0,175,0,200,187,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Linux PB Image")

StartDrawing(WindowOutput())
  imgid = UseImage(1)
  DrawImage(imgid,45,45,99,114)
StopDrawing() 
 
Repeat
  EventID=WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow

End
Fred
Administrator
Administrator
Posts: 18254
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

This function is not implemented, I'm on it.
Beach
Enthusiast
Enthusiast
Posts: 677
Joined: Mon Feb 02, 2004 3:16 am
Location: Beyond the sun...

Post by Beach »

I'm just curious, had DrawImage worked before 3.91? :roll:

<edit>
I re-loaded 3.81 and DrawImage did not work either. It does not matter now, I was able to finally get an image to display using a ImageGadget. This had not worked on previous attempts with a different distro. I assume now that I did not have all of the required items for Linux. Who knows (who cares?)..

Code: Select all

UseJPEGImageDecoder()
FileName$ = "logo.jpg"
LoadImage(1, FileName$)

OpenWindow(0,175,0,200,187,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"Linux PB Image")
  CreateGadgetList(WindowID())
  ImageGadget(0,0,0,200,187,UseImage(1))
 
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Post Reply