Jump to content

drawImage quality when image is scaled down on Android


Ezelia
 Share

Recommended Posts

Hello,

 

I'm facing a problem with Android devices when scaling down images with drawImage, they are pixelised . while on iPad/iPhone the quality is excellent.

 

I noticed the same issue with Firefox/Chrome (desktop version), but since the game will not be scaled down on desktops it's not much an issue as on mobiles.

 

do you know how can I preserve quality (actually apply anti-aliassing) without costy techniques like imageData manipulation ?

 

thank's :)

Link to comment
Share on other sites

As far as I know you can stretch or reduce a canvas image in 2 ways:
  1. use drawImage
  2. use css
From your question, I assume you use drawImage for example like this?:
mycanvas.drawImage(myimg, 0,0,320,480, 0,0,160,240)

You could try changing the size using CSS. Maybe that will give a better result? The advantage of this is also that you can always draw to the canvas as if it's a fixed resolution, you don't have to handle any scaling or zoom factor etc. in your javascript code. I mean something like this:

/* in your css */#thecanvas {padding: 0px;width: 160px;height: 240px;}/* in your html */<canvas id="thecanvas" width="320" height="480"></canvas>

Also see this question on stack overflow: http://stackoverflow.com/questions/18922880/html5-canvas-resize-downscale-image-high-quality

 

Link to comment
Share on other sites

An idea of me: Scale your canvas via css like BdR mentioned. So use the doubled value for the width and heigth property of the canvas as in CSS. Then scale the Context of the canvas via ctx.scale(2,2)

 

If you draw an image normal there should be no difference (else set imagesmoothingenabled false) and if you scale an image down it might have a better quality

 

hope it helps

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...