SetViewPort on canvas broken?

BlitzMax Forums/BlitzMax Programming/SetViewPort on canvas broken?

Beaker(Posted 2006) [#1]
Can you test this? (requires MaxGUI)
win = CreateWindow("blah",50,50,500,500)

canv = CreateCanvas(0,0,400,400,win)
	SetGadgetLayout canv,1,0,1,0
	SetGraphics CanvasGraphics(canv)

img = LoadImage("sheep2.jpg")

SetViewport 50,50,50,50

Cls
DrawImage img,0,0
Flip

Delay 4000
End

I get a long vertical strip instead of a small square as you could expect. Looks like the Y component of the viewport doesn't do anything.

Is it just me?


CS_TBL(Posted 2006) [#2]
It's not just you.. I mentioned this in the bugbin ages ago .. but no 'confirm' from anyone, nothing.. Highly irritating for map-editors 'ns stuff.


Beaker(Posted 2006) [#3]
Can you link me up to the your bug report so I can prod it?


CS_TBL(Posted 2006) [#4]
ehrm.. now I start to doubt it :P I do know I mentioned it there, but there's no dedicated topic from me it seems.
It could be that someone else talked about it and I confirmed it, could be just a mentioned issue in a topic about other bugs.. :P

For safety: make a new topic about it, better an extra topic than an extra bug I'd say.. ^_^


Yan(Posted 2006) [#5]
Hmm...Works fine here.

This...

Gives me this...


Diablo(Posted 2006) [#6]
works here too.


CS_TBL(Posted 2006) [#7]
before anything, I'm using 1.16, 1.18 refuses to work here.

Anyway:

That example from Hamish is actually the good-case-scenario.

I think most ppl use viewport to fill-up the gap left by the lack of DrawImageRect (the proper one, not the one in bmax), for which we need a viewport and negative x/y coords for the image to draw.
Try this stuff, and notice the different x/y coords at the draw-/tileimage commands!
SuperStrict
Local window:TGadget=CreateWindow("o.O",32,32,640,480)
Global canvas:TGadget=CreateCanvas(32,32,256,256,window)

Global image:TImage=CreateImage(64,64)
Local x:Int
Local y:Int
Local i:Int
Local pm:TPixmap=LockImage(image)
	For y=0 To 63
		For x=0 To 63
			i=Rnd(255)-(x*2)-(y*2)
			If i<0 i=0
			WritePixel pm,x,y,$ff000000|i+256*(255-i)+65536*i
		Next
	Next
UnlockImage image

SetGraphics CanvasGraphics(canvas)

Repeat
	WaitEvent()
	If EventID()=EVENT_WINDOWCLOSE End
	If EventSource()=canvas update
Forever

Function update()
	SetViewport 0,0,256,256
	Cls
	SetViewport EventX(),EventY(),32,32
	

	' try em all! (but just one at a time eh!)
	'
	'
	
		
	' works!
	TileImage image,EventX(),EventY()

	' works!
'	DrawImage image,EventX(),EventY()

	' you GOTTA *love* this effect ^_^
'	TileImage image,0,0

	' also buggy
'	DrawImage image,0,0
				
	
	Flip
End Function



Dreamora(Posted 2006) [#8]
Posting errors for an outdated and already updated and fixed version is quite ... lets say useless?

Its broken in 1.16 and fixed with 1.18, there is nothing that could be done on that.


Beaker(Posted 2006) [#9]
Er.. I'm using 1.18! And Hamishs code has the same problem.


Beaker(Posted 2006) [#10]
So, is it just me then?


Beaker(Posted 2006) [#11]
Dreamora - why do you say it has been fixed? Do you have a link to an existing bug report, or thread where this has been mentioned?