It is currently Sat Oct 21, 2017 2:35 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 41 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Tue Jun 19, 2012 3:53 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Dwedit is right that the problem comes from using nearest neighbor resampling, which just doubles rows or columns of pixels. You want to use some sort of interpolation.

I will warn you that bilinear interpolation will blur the image. If you're resizing to 2x or bigger, I recommend upscaling your 256x240 pixel picture to another 512x480 pixel offscreen surface in nearest neighbor mode so that pixels still have well-defined edges, and then using bilinear interpolation from that to the final window.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 4:18 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
Dwedit wrote:
Don't resize to 292x240, enlarge it to something much bigger, but when you pick a new size for the image, keep it at the same ratio as 294x240. So you resize from 256x240 to something bigger, and make the image slightly wider at the same time.

So if you enlarge it to 1920x1080 for example, you get a size of 1317x1080.

If you will be keeping the image small, it's best not to correct the aspect ratio. But it works well for enlargements.

Also, when you resize, you want a resizing algorithm that interpolates the image.


mmm.. i googled for "image interpolation" and is a big topic. I found a PDF that threat that topic, but is out of my scope, in the sense i can't understand it. It's full of math examples and all things like that.
I also searched for a library or code to do interpolation but there is no one!!. Maybe i should try with a game dev book, something simpler.

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 4:47 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Note: These images come from an emulator that trims off the top and bottom 8 scanlines as overscan before doing any other processing, and please don't nitpick the palette either.

Image
SMB1 title screen, dot for dot

Image
SMB1 title screen, resized to 292x224 with point sampling (nearest neighbor)
Notice how uneven the ground is because some NES pixels become 1 screen pixel wide and others become 2.

Image
SMB1 title screen, resized to 292x224 with linear interpolation
Nice and smooth.

Image
SMB1 title screen, resized to 584x448 with point sampling
Notice that the ground's still uneven, but less so than at 292x224, because some NES pixels become 2 screen pixels wide and others become 3.

Image
SMB1 title screen, resized to 584x448 with linear interpolation
It's smooth, almost too smooth, because linear interpolation applies a blur over everything.

Image
SMB1 title screen, resized to 512x448 with point sampling and then to 584x448 with linear interpolation
The first step of doubling ensures that pixel edges remain well defined; the linear step keeps them smooth. This is what your emulator's output should look like if you're not planning to emulate NTSC video artifacts.

Image
SMB1 title screen, resized to 512x448 with Scale2x and then to 584x448 with linear interpolation
Scale2x doesn't do much for 45 degree lines, but look at what it does to the text, bushes, and floor.

DirectX itself can perform point sampling and linear interpolation. External libraries are available to apply the Scale2x effect, and it's even been done in a pixel shader.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 5:45 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
Quote:
DirectX itself can perform point sampling and linear interpolation

But you said "DirectX", not "Direct Draw" im going now for a tutorial for Direct3D!! I found one that's seems pretty good.
Thxs!!

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 6:33 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
People still use DirectDraw?

Is surface blitting even still supported by modern hardware?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 7:01 pm 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
Disch wrote:
Is surface blitting even still supported by modern hardware?

Nvidia cards only do point sampling on Vista+. I switched to Direct3D because of this.

I'm using the method described here for resizing. It results in a smooth image, but edge detail is better preserved than with straight bilinear filtering.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 7:11 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
Disch wrote:
People still use DirectDraw?

Yes me untiil up now :D

Everyone knows a good book for learning d3d??
Well i will google it...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 7:27 pm 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
I have this book and think it's pretty good.

_________________
get nemulator
http://nemulator.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 7:30 pm 
Offline
User avatar

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
James wrote:
I have this book and think it's pretty good.

I'm taking note...

_________________
ANes


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 9:57 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3943
DirectDraw is faster than Direct3D on Windows XP. Not so much on newer OSes though.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 10:04 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
I would think the video card/drivers would matter more than the OS.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 10:26 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10066
Location: Rio de Janeiro - Brazil
Anes wrote:
Image

OT: Don't use JPG for NES screenshots (or any other image with few colors and flat-colored areas), it severily degrades the image and results in bigger files than GIF or PNG, which are lossless. Your image is 35KB, and it's all blurry and ruined by JPG artifacts. Compare it to tepples' image:

Image
This is a perfect representation of the original image, with no degradation of any kind, and is under 2KB in size (it's over 17 times smaller, and looks much better!). JPG is for photographs and real-world stuff, for pixel art always use GIF or PNG.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2012 11:09 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
Also, don't forget that scaling is different on DDraw than D3D (regardless of OS). There are those of us who do not like the blurry filter crap output when using an emulator, even when using an even number (e.g. display size of 512x448). I prefer my graphics to look pixellated rather than blurry as shit, but that's also why I use an even multiple (*2) for my display resolution. Oh, and full screen vs. windowed seems to matter too. You can look all the many emulators out there which all let you toggle this kind of feature (GPU scaling vs. software); each calls it something different, which amuses me.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2012 4:34 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
(Let the record state that that book is Introduction to 3D Game Programming with DirectX 10 by Frank D. Luna.)

The biggest problem that I can see with DirectX 10 is that it's new in Windows Vista, which means 45 percent of people still can't run it according to this table:
Net Market Share wrote:
Windows XP: 44.85%

I already don't have any XP boxes in my home anymore since I replaced the last one with a new PC running Windows 7 nearly a year ago, but my aunt and her kids still have four. It'll take a couple more years (April 2014) for Windows XP to leave extended support.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 20, 2012 5:29 am 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
The author also wrote DirectX 9 versions of the book: with shaders and without.

IMO, if you're starting now, go for DX10/11, or at the very least, take the shader approach. Or, if you're really worried about broad platform compatibility, look at OpenGL instead.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group