How can I change the scale mode for a canvas ?

BlitzPlus Forums/BlitzPlus Programming/How can I change the scale mode for a canvas ?

skn3(Posted 2004) [#1]
Currently when you resize a canvas, it will scale the contents. This is good, but I need a way to change the way it scales. What I mean is, currently it will scale and apply a really nasty blurr. I know it is possible to do a simple resize as shown below.

I have a dual monitor setup. When the canvas is on the primary monitor, it does the nasty blurr effect



When I move the window over to my secondary monitor, it disables the blurr.



So it is possible, but does anyone know how to switch it to the simple pixel resize, perminantly ?

I know you can't in blitz, but surely there most be a way to do it with a userlib / dll. I have looked hard on the msdn site, but could not find anything.


soja(Posted 2004) [#2]
Interesting. When you move it back, does it revert to how it was?


skn3(Posted 2004) [#3]
It does yes. when the canvas next redraws (ie resized etc)


soja(Posted 2004) [#4]
So if you resize it in one display, move it the the other, and resize it again, it will be blurry in both displays no matter how many times you move it back and forth again?

It sounds like it's being controlled by the display driver, not necessarily Windows. Does that seem right?

And to qualify -- you DO want the canvas scaled, but you DON'T want it blurry. Is that right? Or do you just want a bigger canvas but the same-sized images?


skn3(Posted 2004) [#5]
If the canvas is on the primary display, and it has been scaled. If I draw to it then flip, it will be blurred.

If I moved it over to the secondary display, draw, flip.. then it is not blurred.

I (topic title) want to be able to set it to none blur scale mode, perminantly. (or optionally)


Orca(Posted 2004) [#6]
I noticed this awhile back. It suxx0r the big c0xx0r...I think style settings should be added to canvas's for this.

I'm thinkin something like:

0 - default
1 - no filtering/blur
2 - noscale ( so we dont have to recreate the canvas during a resize, to keep our graphics the same size)

I think I'm gonna add this to the long "coming soon!" thread.


skn3(Posted 2004) [#7]
Deffinatly.. this would be great. (not so worried about option 2, as you can do it easily with a canvas & panel)

but options 1 and 0 are a must!


skn3(Posted 2004) [#8]
I found a "thread" about this from a mame emulator. It had a -sharp flag, which set the stretch to non blurr.

Which lead me too a page about DD caps, which lead me to a page describing them.

Here is a possible solution (not sure it is what we are after):
DDSCAPS_OFFSCREENPLAIN
Indicates that this surface is any off-screen surface that is not an overlay, texture, z-buffer, front-buffer, back-buffer, or alpha surface. It is used to identify plain surfaces.



Orca(Posted 2004) [#9]
(not so worried about option 2, as you can do it easily with a canvas & panel)


What I meant was, allowing the canvas to grow, yet keeping the same pixel size of everything....

ie, say you have a canvas that grows with the parent window. Currently, blitz scales the pixels on that canvas. It would be nice to have the option to keep the pixel aspect the same, and just have the canvas grow/shrink....its really annoying to have to free, and then recreate the canvas and then redraw everything to it.


skn3(Posted 2004) [#10]
What I meant was, allowing the canvas to grow, yet keeping the same pixel size of everything....


Const maximumcanvassize = 2048

Global window = CreateWindow("Test window - resize me",(ClientWidth(Desktop())/2)-250,(ClientHeight(Desktop())/2)-210,500,420,0,1+2)
Global panel  = CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,True)
	SetGadgetLayout(panel,1,1,1,1)
Global canvas = CreateCanvas(0,0,maximumcanvassize,maximumcanvassize,panel)
	SetGadgetLayout(canvas,1,0,1,0)

Repeat
	Select WaitEvent()
		Case $203
			SetBuffer CanvasBuffer(canvas)
			Color Rand(0,255),Rand(0,255),Rand(0,255)
			w = Rand(0,100)
			h = Rand(0,100)
			Oval EventX()-(w/2),EventY()-(h/2),w,h,1
			FlipCanvas(canvas)
		Case $803 : Exit
	End Select
Forever


You can, like I said ;)


Orca(Posted 2004) [#11]
No, all your doing is creating a giant canvas :)

What if I have an application with multiple canvas'd windows? Think of something like photoshop.... I don't see creating giant canvas's as being a good solution to this.

I still think that the style/option I mentioned is a worthwhile tidbit for the blitzgods to look into...


skn3(Posted 2004) [#12]
It's not sensible to constantly re-allocate large chunks of memoery like this. Creating the maximum space you want a chunk of memoery to be able to take up, is standerd practice. It applies in exactly the same manner to a graphics buffer.

All that a canvas in the way you suggest would do, is constantly create new, copy bits from old to new, destroy old.

Although! a ResizeCanvas(canvas,w,h) that copies the existing data intao resized canvas.. would be good :)