Slick Forums

Discuss the Slick 2D Library
It is currently Thu May 23, 2013 1:01 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sat Jun 23, 2012 2:52 pm 
Offline

Joined: Sat Jun 23, 2012 2:43 pm
Posts: 7
Hi guys,

I'm trying to make health bar with 1px wide slices... but for some reason whenever I try to draw an image that's less than 3px wide, the pixels get all whack.

The image I'm loading is a .gif. I tried .png too and that doesn't fix it.

Attached is a screenshot of what it looks like when the .gif is 2px wide, and another screenshot of when it's 3px wide.

As far as I can tell there's nothing wrong with the file. I exported it via Save For Web in Photoshop CS6.

Also, I'm using g.scale() and I have a nearest neighbor filter on the image; Although taking those off doesn't fix the problem.


Attachments:
File comment: 3px wide .gif
Screen shot 2012-06-23 at 10.45.57 AM.png
Screen shot 2012-06-23 at 10.45.57 AM.png [ 6.26 KiB | Viewed 467 times ]
File comment: 2px wide .gif
Screen shot 2012-06-23 at 10.45.16 AM.png
Screen shot 2012-06-23 at 10.45.16 AM.png [ 6.34 KiB | Viewed 467 times ]
Top
 Profile  
 
PostPosted: Sat Jun 23, 2012 8:48 pm 
Offline
Regular
User avatar

Joined: Thu May 05, 2011 8:35 pm
Posts: 231
Location: Somewhere between the bits and bytes
Why would you ever need a Image that small?
Why not just draw a small rectangle in the right color?

_________________
For every new problem, a new source of solutions has come to exist.


Top
 Profile  
 
PostPosted: Sat Jun 23, 2012 9:04 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1469
I can think of a couple advantages:
  • Using sprite sheets, it allows you to minimize state changes and flush more data at once to the GPU. i.e. Using startUse/endUse/drawEmbedded, or Image.draw() and VertexArrayRenderer. In simple terms: it can lead to better performance.
  • Drivers may implement line/polygon rendering slightly differently, i.e. with anti-aliasing, one pixel differences, etc. For the sake of consistency, it's better to just use an image.

And of course you may want a 1x2 or 2x1 image with different colours, so you could stretch it into the shape of an "embossed" horizontal/vertical rule:
Image

I'll look into the issue.


Top
 Profile  
 
PostPosted: Sun Jun 24, 2012 12:02 am 
Offline
Regular
User avatar

Joined: Thu May 05, 2011 8:35 pm
Posts: 231
Location: Somewhere between the bits and bytes
Forgot about embossing. :oops:

Anyway when i said "Draw a small rectangle" i meant fillRect(), that draws a quad just like the images do, so if there's any one pixel differences, they'll happen on images as well anyway.

_________________
For every new problem, a new source of solutions has come to exist.


Top
 Profile  
 
PostPosted: Sun Jun 24, 2012 5:39 am 
Offline

Joined: Sat Jun 23, 2012 2:43 pm
Posts: 7
Thanks for the help!

Yeah the reason why I was using an image is because I actually want it to be multiple colors and not a solid rectangle.

Right now I'm using 3px wide images but drawing them so that they overlap, and then the bar only grows 1px at a time. It's not perfect, but barely noticeable unless you know it's happening, so it should do for now.


Top
 Profile  
 
PostPosted: Sun Jun 24, 2012 1:58 pm 
Offline

Joined: Sat Jun 23, 2012 10:16 pm
Posts: 19
I wonder if it could be to do with not using power of two textures, I'm pretty sure that's where most texturing issues arise?


Top
 Profile  
 
PostPosted: Sun Jun 24, 2012 4:47 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1469
messd002 wrote:
I wonder if it could be to do with not using power of two textures, I'm pretty sure that's where most texturing issues arise?

Yep -- if he used a power of two texture (2x2 for example) then it should work.

Still a bug in Slick, though -- I'm getting weird colours, plus it seems like Slick doesn't consider 1x1 a valid texture size.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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