Page 1 of 1

Can't DrawImage() within another image?

Posted: Wed Mar 03, 2004 5:28 am
by Derlidio
Yeepy...

Following the steps of my "Test List" I did stubbed another brick using 2D Drawing functions under Linux (please, do not call me bad names, I'm just playing my part).

I try to draw a loaded image (256 color bitmap format little image) inside another (far larger than the first one and created with CreateImage() function). Under WinXP it runs OK, but (for my despair) under Linux it does not. The program crashes without returning any error message.

Is it a BUG or there is a trick I don't know yet? I'll put some code below. The code is a little long becouse I open a console and print various messages in order to know what is happening).

Code: Select all

#CreatedImage=1
#LoadedImage=2
#MainWindow=3
#CreatedGadget=4

OpenConsole()

PrintN("")
PrintN("There are 10 steps to walk through.")
PrintN("When reach step 10 a console and a window must stay open")
PrintN("")

If CreateImage(#CreatedImage,320,200)
   PrintN("1/10 - Image creation OK using #CreatedImage...")
   If LoadImage(#LoadedImage,"img.bmp")
      PrintN("2/10 - Image load OK using #LoadedImage...")
      If OpenWindow(#MainWindow, 0, 0, 320, 200, #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered, "Testing, 1, 2, 3...")
         PrintN("3/10 - Window creation OK using #MainWindow...")
         If CreateGadgetList(WindowID(#MainWindow))
            PrintN("4/10 - GadgetList creation OK...")
            ImageGadget(#CreatedGadget, 0, 0, 320, 200, UseImage(#LoadedImage))
            PrintN("5/10 - ImageGadget creation OK using #CreatedGadget. Pointing To #LoadedImage.")
            PrintN("6/10 - Main test: now lets draw to #CreatedImage...")
            UseImage(#CreatedImage)
            If StartDrawing(ImageOutput())
               Box(0,0,320,200,RGB(255,255,255))
               StopDrawing()
            EndIf
            PrintN("7/10 - The whole image was painted white. Lets display it.")
            SetGadgetState(#CreatedGadget,UseImage(#CreatedImage))
            PrintN("8/10 - Now lets draw the loaded image into the created image.")
            LID=UseImage(#LoadedImage)
            UseImage(#CreatedImage)
            If StartDrawing(ImageOutput())
               PrintN("9/10 - StartDrawing to ImageOutput() returns OK.")
               DrawImage(LID,50,50)
               StopDrawing()
            EndIf
            PrintN("10/10 - The loaded image was painted into the created image. Lets show it...")
            SetGadgetState(#CreatedGadget,UseImage(#CreatedImage))
            Repeat
               E = WaitWindowEvent()
               If E = #PB_Event_CloseWindow
                  MessageRequester("Bye Bye", "Leaving...")
                  CloseConsole()
                  FreeImage(#CreatedImage)
                  FreeImage(#LoadedImage)
                  Break
               EndIf
            ForEver
         EndIf
      EndIf
   EndIf
   
EndIf     

End

Posted: Wed Mar 03, 2004 12:40 pm
by Fred
Seems like a bug, i will take a look.

Posted: Mon Jul 05, 2004 3:33 am
by freak
I am unable to reproduce this error (PB 3.91 beta 2), sorry.
Can anybody else confirm this?

Timo