Acknowledged
over 1 year ago

setMatrix bug?

Had some affinetransforms which worked well in sim but not on my FR265 device (on-device log file reports ciq 4.2.4).

Wittled down to a test case which works in sim but not on device (bitmap not showing up how it should):

translateMatrix.initialize();
translateMatrix.setMatrix([
    1.0, 0.0, 0.0,
    0.0, 1.0, 0.0]);
dc.drawBitmap2(200, 200, myPngBitmap, {
  :transform => translateMatrix,
  :filterMode => Graphics.FILTER_MODE_BILINEAR
});

AFAIK it should be equal to the following code, which does work as expected on-device:

translateMatrix.initialize();
translateMatrix.setToTranslation(0.0, 0.0);
dc.drawBitmap2(200, 200, myPngBitmap, {
  :transform => translateMatrix,
  :filterMode => Graphics.FILTER_MODE_BILINEAR
});

I've had to change my real code from doing multiple operations in setMatrix/concatenate to using separate translate/scale/rotate operations.

  • Is there any update or workaround for the setMatrix bug fix,

  • I totally understand. Our documentation isn't the best, but object initializers should be treated like a constructor in C++ or Java.

    You're not the first person to do this. I just want to discourage it so we don't break your application in cases where initialize makes assumptions about the object state (we could easily assume that the object is not yet initialized when initialize is called and leak a resource).

    The compiler doesn't currently prevent it, but this is probably something we should do.

  • Just wanted to "reset" to identity transform. There's nothing in the docs indicating it's not a normal method ...

  • There was a typographical error in the underlying matrix class implementation. The z-scale value, which isn't accessible from the AffineTransform interface, was getting set to 1.1 instead of 1.0. This caused the underlying functionality to misbehave.

  • Just a note while I'm here looking at your issue... Outside of calling your base class initialize, you should never call a classes initialize method directly. If you want a matrix, use a new expression to allocate and initialize it.

    var translateMatrix = new Graphics.AffineTransform();
    translateMatrix.setMatrix([
      ...
    ]);
    

    If you want to re-initialize an object, either allocate a new one and assign, or call a normal method to get the state you want.