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

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

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Out of scope
    • Affects Version/s: 5.0.2, 5.1.0 , 5.1.1
    • Fix Version/s: None
    • Labels:

      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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes