possible bug in drawImage

Posted on
  • Good morning!

    I was just experimenting with image rotation when I found the following problem:

    if you drawImage an image including rotation and a non-default centerx/centery, the image gets cut in half.


      const Width  = g.getWidth(),  CenterX = Width/2;
      const Height = g.getHeight(), CenterY = Height/2;
      let MinutesHandle = {
        width:96, height:4, bpp:1,
      g.drawImage(MinutesHandle, CenterX,CenterY);
      g.drawImage(MinutesHandle, CenterX,CenterY, {

    in emulator or on watch and see what I mean.

  • Thanks - I've just filed an issue for that here: https://github.com/espruino/Espruino/iss­ues/1742

    So it works fine without centerx/y specified?

  • yes, that's why I had two drawImage calls in my example: the first one looks ok

  • Ah,

    I forgot that I removed the properly working call from the example, thus: yes, without specifying centerx/centery, rotation seems to work.

  • Out of interest, do you have a potential use-case for centerx/centery? Because if there isn't a good reason to have them I may just remove them.

  • Well, I was just experimenting with custom clock handles that needed this non-centric rotation point - but, of course, I could also do the required math myself.

    Just tell me/us, if you plan to drop that feature. There are other ones which are more important (drawing a bitmap directly from file, for example...)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

possible bug in drawImage

Posted by Avatar for Andreas_Rozek @Andreas_Rozek