Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-33167

CanvasPixelData converts to empty QVariant when passed as parameter to native method

    XMLWordPrintable

Details

    Description

      An example demonstrates:

      var ctx = canvas.getContext('2d');
      var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
      nativeMethod(imageData.data, imageData.width, imageData.height);
      

      Internally the Qt5V8 method "toVariant" is called to convert the array to a QVariant. Because this object is actually a custom type (and not a proper V8 Array type) it requires special handling which isn't implemented. Instead an empty QVariant is returned.

      var copied = new Array();
      for( var x=0; x < imageData.data.length; x++ )
          copied[x] = imageData.data[x];
      nativeMethod(copied, imageData.width, imageData.height);
      

      This works as expected since the data is moved into a V8 "Array" first, but I'd rather not have to do this for hopefully obvious reasons.

      Attachments

        Activity

          People

            aalpert Alan Alpert
            doneill d francis o'neill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: