Take the 2-minute tour ×

I have a problem with the context2d's drawImage function. Whenever I scale an image, it gets a dark border of one pixel, which is kind of ugly. That does only happen in Firefox, not in Opera or Webkit.

Is this an antialiasing problem? For hours I studied the examples and available documentation without getting rid of it... I couldn't yet try it on another computer so maybe just maybe it's an issue with the graphics hardware/drivers.

I have reproduced this effect with this minimal snippet, assuming exp.jpg is sized 200x200 pixels.

   <script type="text/javascript" src="../../media/pinax/js/jquery-1.3.2.min.js"></script>

<script type="text/javascript" >
  context = $('#canvas')[0].getContext('2d');
  img = new Image();
  img.src = "exp.jpg";
  //while (!img.complete);
  context.drawImage(img, 2,2,199,199);
  context.drawImage(img, 199,2,199,199); 
share|improve this question
I tried this code but don't see any dark border. This is with Firefox 3.5.3 on Windows. I think it would make it easier for people to test this if you had left out the jquery requirement. –  user181548 Oct 10 '09 at 9:10
yes you're right... I also forgot to say I have to scale the page in firefox to make the effect clear. However, I am using this in an effort to draw tiled images, and then it gets really annoying. But thanks for trying. –  user187566 Oct 10 '09 at 12:57
You can just grab the jQuery off Google to avoid dependency problems: ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js I did a test page: boogdesign.com/examples/canvas/image.html Looks fine for me, FF 3.5.3 on Linux: boogdesign.com/examples/canvas/Canvas_test_ff.png –  robertc Oct 10 '09 at 21:28
Why do you have script tags after body? –  kangax Oct 12 '09 at 4:13
The browser will stop loading the page to load any scripts it comes across. If the scripts are the last thing on the page (after the body) then they won't hold up page loading and you also can be sure all the DOM objects you might want to access in your script have been loaded. –  robertc Oct 21 '09 at 2:38
add comment

1 Answer

This is a known Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=490997 It seems to be a X11/driver issue.

share|improve this answer
add comment

Your Answer

