Scale window or zoomed out view option?
Scale window or zoomed out view option?
Is there a way to have a program draw on a window, of say, 1000x1000px, so that it can be previewed on screen, but it is actually generating an image of 4000x4000px, of which the view is merely being zoomed out to view 4 times smaller?
Re: Scale window or zoomed out view option?
Check: ResizeImage()
Re: Scale window or zoomed out view option?
Thanks!!! I will try that!!!!!!!!
Re: Scale window or zoomed out view option?
I'm not sure that Resizeimage() does what I want actually.
I want to be able to continuously draw to screen and have what the screen sees as 1/4 the size of the actual being generated.
Resizeimage() seems to just change the size of an already prepared image.
I want to be able to continuously draw to screen and have what the screen sees as 1/4 the size of the actual being generated.
Resizeimage() seems to just change the size of an already prepared image.
Re: Scale window or zoomed out view option?
Working with a copy of the image
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Scale window or zoomed out view option?
Okay, I think I get it now, I have tried multiple ways and always get an error, usually that I have not initialised a window at the correct time.
Could someone please show me how I might do it with this small program, that is, to have a preview window of say, 500x500px, that shows what is being generated in the larger window?
I assume that I will have to create a second window, possibly a second image, then copy the big image to the second, resize it, and send that image to the second window, I have been using Copyimage(), Resizeimage(), Setactivewindow(), and I always get some error stopping it from running. The truth is, I don't fully understand the procedure for working with a window and image etc.
I suppose that I do not even need to have the larger image drawn to a window, as I will only ever save it, and not try to view it live. I will need to have the scaled window show the output so that I can see a point when it is worth saving.
There is a reason that I have been using the Openwindowedscreen() though, as it then allows me to use keyboard controls to input to the program.
Could someone please show me how I might do it with this small program, that is, to have a preview window of say, 500x500px, that shows what is being generated in the larger window?
I assume that I will have to create a second window, possibly a second image, then copy the big image to the second, resize it, and send that image to the second window, I have been using Copyimage(), Resizeimage(), Setactivewindow(), and I always get some error stopping it from running. The truth is, I don't fully understand the procedure for working with a window and image etc.
I suppose that I do not even need to have the larger image drawn to a window, as I will only ever save it, and not try to view it live. I will need to have the scaled window show the output so that I can see a point when it is worth saving.
There is a reason that I have been using the Openwindowedscreen() though, as it then allows me to use keyboard controls to input to the program.
Code: Select all
InitKeyboard()
InitSprite()
UseJPEGImageEncoder()
#width=3000
#height=3000
#ImgGadget=0
Global.i x,y,xo,yo,ti,c,h,col
Global.i c=1,re=1,gr=1,bl=1
Global.i reo=1,gro=1,blo=1
x=#width/2:y=#height/2
Global.i h=1:ti=1
Global main=OpenWindow(#PB_Any,10,10,#width,#height,"Drawing")
Global wmain=OpenWindowedScreen(WindowID(main),0,0,#width,#height)
Global image=CreateImage(#PB_Any, #width,#height)
ImageGadget(#ImgGadget, 0, 0, #width, #height, ImageID(image))
Procedure SDRAW()
StartDrawing(ImageOutput(image))
Circle(Random(1800,200),Random(1800,200),Random(200,1),Random(16777216,1))
StopDrawing()
EndProcedure
Repeat
ExamineKeyboard()
Event = WindowEvent()
SDRAW()
SetGadgetState(#ImgGadget, ImageID(image))
;Delay(100)
If Event = #PB_Event_CloseWindow
End
EndIf
If KeyboardPushed(#PB_Key_Escape)
quit=#True
EndIf
If KeyboardPushed(#PB_Key_Space)
Delay(800)
EndIf
If KeyboardPushed(#PB_Key_W)
SaveImage(image,"Randraw - "+FormatDate("%yyyy%mm%dd_%hh%ii%ss", Date())+Str(Random(9999,1))+".bmp", #PB_ImagePlugin_BMP)
Delay(500)
EndIf
If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
Quit=#True
ElseIf Event = #PB_Event_Gadget
EventGadget = EventGadget()
Select EventGadget
EndSelect
EndIf
Until quit=#True
Re: Scale window or zoomed out view option?
I got it working here, although, I'm not sure it is as fast as it could be.
Does anyone know why there is a point where the screen flickers black at the beginning of each running of the program?
Does anyone know why there is a point where the screen flickers black at the beginning of each running of the program?
Code: Select all
InitKeyboard()
InitSprite()
UseJPEGImageEncoder()
#width=1000
#height=1000
#height1=4000
#width1=4000
#ImgGadget=0
Global.i x,y,xo,yo,ti,c,h,col
Global.i c=1,re=1,gr=1,bl=1
Global.i reo=1,gro=1,blo=1
x=#width/2:y=#height/2
Global.i h=1:ti=1
Global main=OpenWindow(#PB_Any,10,10,#width,#height,"Drawing")
Global wmain=OpenWindowedScreen(WindowID(main),0,0,#width,#height)
Global image=CreateImage(#PB_Any, #width1,#height1)
ImageGadget(#ImgGadget, 0, 0, #width1, #height1, ImageID(image))
Global imagesc=CreateImage(#PB_Any, #width,#height)
ImageGadget(#ImgGadget, 0, 0, #width, #height, ImageID(imagesc))
Procedure SDRAW()
StartDrawing(ImageOutput(image))
Circle(Random(3800,200),Random(3800,200),Random(200,1),Random(16777216,1))
StopDrawing()
EndProcedure
Repeat
ExamineKeyboard()
Event = WindowEvent()
SDRAW()
CopyImage(image,copy)
ResizeImage(copy,1000,1000)
StartDrawing(ImageOutput(imagesc))
DrawImage(ImageID(scaled),0,0)
StopDrawing()
SetGadgetState(#ImgGadget, ImageID(imagesc))
;FlipBuffers()
;Delay(100)
If Event = #PB_Event_CloseWindow
End
EndIf
If KeyboardPushed(#PB_Key_Escape)
quit=#True
EndIf
If KeyboardPushed(#PB_Key_Space)
Delay(800)
EndIf
If KeyboardPushed(#PB_Key_W)
SaveImage(image,"Randraw - "+FormatDate("%yyyy%mm%dd_%hh%ii%ss", Date())+Str(Random(9999,1))+".bmp", #PB_ImagePlugin_BMP)
Delay(500)
EndIf
If Event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
Quit=#True
ElseIf Event = #PB_Event_Gadget
EventGadget = EventGadget()
Select EventGadget
EndSelect
EndIf
Until quit=#True
Re: Scale window or zoomed out view option?
Hi
Code: Select all
If OpenWindow(0, 0, 0, 1000, 800, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 10, 980, 780, #PB_Canvas_Container)
CanvasGadget(1, 720, 5, 250, 200,#PB_Canvas_Border)
ButtonGadget(2, 10, 740, 80, 30, "Show")
CloseGadgetList()
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(0))
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
GrabDrawingImage(1,0,0,OutputWidth(),OutputHeight())
StopDrawing()
ResizeImage(1,245, 195)
SetGadgetAttribute(1,#PB_Canvas_Image ,ImageID(1))
EndIf
EndIf
Case 2
Run ! 1
If Run = 1
HideGadget(1,1)
Else
HideGadget(1,0)
EndIf
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Egypt my love
Re: Scale window or zoomed out view option?
Thanks Rashad, that is a good example.RASHAD wrote: ↑Sat Jul 24, 2021 4:12 am HiCode: Select all
If OpenWindow(0, 0, 0, 1000, 800, "Canvas container example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) CanvasGadget(0, 10, 10, 980, 780, #PB_Canvas_Container) CanvasGadget(1, 720, 5, 250, 200,#PB_Canvas_Border) ButtonGadget(2, 10, 740, 80, 30, "Show") CloseGadgetList() Repeat Event = WaitWindowEvent() If Event = #PB_Event_Gadget Select EventGadget() Case 0 If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton) If StartDrawing(CanvasOutput(0)) x = GetGadgetAttribute(0, #PB_Canvas_MouseX) y = GetGadgetAttribute(0, #PB_Canvas_MouseY) Circle(x, y, 10, RGB(Random(255), Random(255), Random(255))) GrabDrawingImage(1,0,0,OutputWidth(),OutputHeight()) StopDrawing() ResizeImage(1,245, 195) SetGadgetAttribute(1,#PB_Canvas_Image ,ImageID(1)) EndIf EndIf Case 2 Run ! 1 If Run = 1 HideGadget(1,1) Else HideGadget(1,0) EndIf EndSelect EndIf Until Event = #PB_Event_CloseWindow EndIf