Page 1 of 1

Hot to WindowedScreen AutoStetch sharpen quality? off smooth

Posted: Wed Nov 01, 2017 9:08 pm
by Didaktik
My friend create game. This similar ZX Spectrum graphics.
Have screen 256x192. And use AutoStretch to resize screen X2 or X3.
But seems very smooth, not pixel perfect.

Is it possible to do some kind of trick for Windows so that the picture is not blurred?

Image

Re: Hot to WindowedScreen AutoStetch sharpen quality? off sm

Posted: Wed Nov 01, 2017 10:19 pm
by #NULL
IIRC, i never experienced blurriness with autostrech on Windows, and currently i can't produce any blurriness on Linux. I used that often for x2,x3,x4 scaling.
not shure if this helps :P

...I just tried it. To my surprise drawing on the Screen directly interpolates smoothly, whereas displaying a Sprite interpolates pixelsharp. I never realized that :)
resize the window to test.

Code: Select all

InitSprite()
InitKeyboard()

ww=100
wh=100
sw=ww
sh=wh

win=OpenWindow(#PB_Any, 50,100, ww,wh, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
OpenWindowedScreen(WindowID(win), 0,0, sw,sh, 1,0,0)

spr = CreateSprite(#PB_Any, 50,50, #PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(spr))
	DrawingMode(#PB_2DDrawing_Outlined | #PB_2DDrawing_AllChannels)
	For i=0 To OutputWidth() Step 2
		For k=0 To OutputWidth() Step 2
			Box(i,k,1,1, $ff00ff00)
		Next
	Next
StopDrawing()


Repeat
	ExamineKeyboard()
	
	Repeat
		event = WindowEvent()
		Select event
			Case #PB_Event_CloseWindow
				quit = #True
		EndSelect
	Until Not event
	
	StartDrawing(ScreenOutput())
		DrawingMode(#PB_2DDrawing_Outlined | #PB_2DDrawing_AllChannels)
		For i=0 To OutputWidth() Step 2
			For k=0 To OutputWidth() Step 2
				Box(i,k,1,1, $ff00ff00)
			Next
		Next
	StopDrawing()
	
	DisplaySprite(spr, 0,0)
	
	FlipBuffers()
	ClearScreen($333333)
Until quit Or KeyboardPushed(#PB_Key_Escape)
<edit>
Some ZX Spectrum stuff might have resources left to just draw on a Sprite first and display that on the screen. That might solve the Problem.

Re: Hot to WindowedScreen AutoStetch sharpen quality? off sm

Posted: Thu Nov 02, 2017 6:17 am
by Lunasole
#NULL wrote: ...I just tried it. To my surprise drawing on the Screen directly interpolates smoothly, whereas displaying a Sprite interpolates pixelsharp. I never realized that :)
Interesting, I also though it will blur sprite on scale anyway.
Too bad that ResizeSprite() always produces blur


@Didaktik, so you can use solution #NULL posted (which "truly professionally" is called "Render to texture" ^^).
First you draw all the pixels to a sprite (256x192), then you draw sprite on screen with auto-stretch and it's scaled without blur:

Code: Select all

InitSprite()

ww=256
wh=192
sw=ww
sh=wh

win=OpenWindow(#PB_Any, 50,100, ww,wh, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget)
OpenWindowedScreen(WindowID(win), 0,0, sw,sh, 1,0,0)

spr = CreateSprite(#PB_Any, 256,192, #PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(spr))
DrawingMode(#PB_2DDrawing_Outlined | #PB_2DDrawing_AllChannels)
For i=0 To ww-1
	For k=0 To wh-1
		Plot(i, k, RGBA(Random(255), Random(255), Random(255), 255))
	Next
Next
StopDrawing()

Repeat
	Repeat
		event = WindowEvent()
		Select event
			Case #PB_Event_CloseWindow
				quit = #True
		EndSelect
	Until Not event
	
	ClearScreen($333333)
	DisplaySprite(spr, 0,0)
	FlipBuffers()
Until quit