Page 1 of 1

Display of two PB "images"

Posted: Wed Dec 10, 2008 2:44 pm
by sospel
Hello!
I have a small problem of display : to compare the behavior of two graphs, I created two "images" in a window to draw a graph in each image. The problem is that only the window and its two images display at once, but graphs appear only if I minimize the window to open again it then, either that I "move" it out of the screen, to return it in the middle of the screen ??!!
To show you what I made, I simplified the program by replacing graphs by one "BOX" and a "CIRCLE".
Could anybody say to me what I badly programmed ?
And also, a supplementary question: why images numbers are the same?
Thank you in advance for your help !!
Sospel
--------------------------------------------------------------
Here is my program :

Code: Select all

   ;
   ; open window n°0 :  ----------------------------------------
   ; 
   ValOptions = 0
   ValOptions = ValOptions | #PB_Window_SystemMenu
   ValOptions = ValOptions | #PB_Window_MinimizeGadget
   ValOptions = ValOptions | #PB_Window_SizeGadget
   N_WinMain = 0
   winhight.F  = 680
   winlarg.F   = winhight * Sqr(2)
   title$         = "MAIN WINDOW"
   OpenWindow(N_WinMain,20,20,winlarg,winhight,title$, ValOptions)
   SetWindowColor(N_WinMain, RGB(192, 83, 70))
   H_WinMain = WindowID(N_WinMain)
   CreateGadgetList(H_WinMain)
   ;
   ; open "image" n°1 ------------------------------------
   N_Image1   = 1
   imaghight.F = winhight * 0.90
   imaglarg.F   = winlarg  * 0.45
   CreateImage(N_Image1,imaglarg,imaghight,32)
   ImageGadget(N_Image1,10,20,0,0,ImageID(N_Image1))
   ident1 = ImageOutput(N_Image1)
   If StartDrawing(ImageOutput(N_Image1))
       Box (80,20,100,200,RGB(221, 120, 34))
       DrawText(100,30,Str(ident1),RGB(0,0,0))
       StopDrawing()   
   EndIf
   ;
   ; open "image" n°2 -------------------------------------
   N_Image2    = 2
   imaghight.F = winhight * 0.60
   imaglarg.F  = winlarg * 0.45
   CreateImage(N_Image2,imaglarg,imaghight,32)
   ImageGadget(N_Image2,500,100,0,0,ImageID(N_Image2))
   ident2 = ImageOutput(N_Image2)
   If StartDrawing(ImageOutput(N_Image2))
        Circle (120,150,90,RGB($40,$40,$FF))
        DrawText(100,100,Str(ident2),RGB(0,0,0))
       StopDrawing()   
   EndIf
   ;
   Repeat 
   Until WaitWindowEvent () = #PB_Event_CloseWindow  
   ;
  End
[/code]

Posted: Wed Dec 10, 2008 2:49 pm
by srod
You need to reposition the ImageGadget() commands :

Code: Select all

; open window n°0 :  ---------------------------------------- 
   ; 
   ValOptions = 0 
   ValOptions = ValOptions | #PB_Window_SystemMenu 
   ValOptions = ValOptions | #PB_Window_MinimizeGadget 
   ValOptions = ValOptions | #PB_Window_SizeGadget 
   N_WinMain = 0 
   winhight.F  = 680 
   winlarg.F   = winhight * Sqr(2) 
   title$         = "MAIN WINDOW" 
   OpenWindow(N_WinMain,20,20,winlarg,winhight,title$, ValOptions) 
   SetWindowColor(N_WinMain, RGB(192, 83, 70)) 
   H_WinMain = WindowID(N_WinMain) 
   CreateGadgetList(H_WinMain) 
   ; 
   ; open "image" n°1 ------------------------------------ 
   N_Image1   = 1 
   imaghight.F = winhight * 0.90 
   imaglarg.F   = winlarg  * 0.45 
   CreateImage(N_Image1,imaglarg,imaghight,32) 
   ident1 = ImageOutput(N_Image1) 
   If StartDrawing(ImageOutput(N_Image1)) 
       Box (80,20,100,200,RGB(221, 120, 34)) 
       DrawText(100,30,Str(ident1),RGB(0,0,0)) 
       StopDrawing()    
   EndIf 
   ImageGadget(N_Image1,10,20,0,0,ImageID(N_Image1)) 
   ; 
   ; open "image" n°2 ------------------------------------- 
   N_Image2    = 2 
   imaghight.F = winhight * 0.60 
   imaglarg.F  = winlarg * 0.45 
   CreateImage(N_Image2,imaglarg,imaghight,32) 
   ident2 = ImageOutput(N_Image2) 
   If StartDrawing(ImageOutput(N_Image2)) 
        Circle (120,150,90,RGB($40,$40,$FF)) 
        DrawText(100,100,Str(ident2),RGB(0,0,0)) 
       StopDrawing()    
   EndIf 
   ImageGadget(N_Image2,500,100,0,0,ImageID(N_Image2)) 
   ; 
   Repeat 
   Until WaitWindowEvent () = #PB_Event_CloseWindow  
   ; 
  End

Posted: Wed Dec 10, 2008 3:08 pm
by Kaeru Gaman
> You need to reposition the ImageGadget() commands :

if the program gets more complicated, this maybe not sufficent.

point is, you have to reassign the images to the gadgets to force a refresh.
so, each time you actualized the images, call a SetGadgetState(N_Image2, ImageID(N_Image2))

Display of two PB "images"

Posted: Wed Dec 10, 2008 4:43 pm
by sospel
OK, these answers clear up my problem :D

Thanks to srod and Kaeru Gaman

Sospel