Zoom In/Out in graphics programs

BlitzPlus Forums/BlitzPlus Programming/Zoom In/Out in graphics programs

skn3(Posted 2003) [#1]
Is this a windows gadget feature that graphics programs like PSP/PS use.

If not, how would you suggest going about it in b+ ?


skn3(Posted 2003) [#2]
anyone ?


Kev(Posted 2003) [#3]
skn3[ac] do you meen where when you select the windows minamize gadget 'top next to close' if so is there anyway of finding out if its possable to get the event return code.

im not sure if thought. then you could just use SetMinWindowSize to resize the window.

also checkout these.
WindowMaximized
WindowMinimized

hope this is of some help
kev


skn3(Posted 2003) [#4]
Nope, didn't mean that. :)


Ratboy(Posted 2003) [#5]
I think you're going to have to do that by hand; I haven't heard of any Windows-native bitmap zoom functions.


assari(Posted 2003) [#6]
Hi,
In the samples folder look under samples\mak\blitzpaint.bb for some sample zoom code.


skn3(Posted 2003) [#7]
Erm I dont see any 'zoom code' but thanks anyway.


assari(Posted 2003) [#8]
The function is called RefreshMag, I have taken the liberty to rewrite it a little.

w=CreateWindow("draw",0,0,200,200)
Global drawcanvas=CreateCanvas(0,0,200,200,w)

w2=CreateWindow("zoom",200,200,400,400)
Global zoomcanvas=CreateCanvas(0,0,400,400,w2)

Repeat
 WaitEvent()
 Select EventID()
  Case $201 ;click mouse on drawcanvas
   If EventSource()=drawcanvas And MouseDown(1)
      SetBuffer CanvasBuffer(drawcanvas)
      Rect MouseX(drawcanvas), MouseY(drawcanvas), 20,20,0
      FlipCanvas drawcanvas
      RefreshMag()
   EndIf
  Case $803
    End
  End Select

Forever

End


Function RefreshMag()
 SetBuffer CanvasBuffer(zoomcanvas)
 dx=0:dy=0
	For y=0 To 200
		For x=0 To 200
			pixel=ReadPixel( x,y,CanvasBuffer(drawcanvas))

			Color pixel Shr 16 And 255,pixel Shr 8 And 255,pixel And 255
			Rect dx,dy,2,2,1
			dx=dx+2
		Next
		dy=dy+2
		dx=0
	Next
	
 FlipCanvas zoomcanvas
End Function




skn3(Posted 2003) [#9]
Oh right yeah, well of course its possible to do that.

I was just interested to see if there was going to be anyway in facilitating a decent speed 'real-time' zoomed canvas


MutteringGoblin(Posted 2003) [#10]
I'd be very surprised if there's a predefined Windows control to do this. There might be something like that in newer professional versions of Visual C - Microsoft say on their website that their aim is to make new components available and easy to share. You might find something for Delphi too.

Anyway, I'm writing a paint program at the moment in C++. I'm going to use GDI stretch-blitting to draw the zoomed image and dotted/dashed pens for the grid.

I think BlitzPlus uses automatic stretch-blitting with canvases if you use the right parameters in SetGadgetLayout. You would have to control the resizing of the window somehow though because some sizes would interfere with the drawing of the grid. (For example, you can't represent one pixel of an image with 3.5 pixels on the screen).