Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display ArrayBuffer in canvas looks scrambled #6

Closed
dnmd opened this issue Nov 17, 2016 · 3 comments
Closed

Display ArrayBuffer in canvas looks scrambled #6

dnmd opened this issue Nov 17, 2016 · 3 comments
Assignees
Labels

Comments

@dnmd
Copy link

dnmd commented Nov 17, 2016

When trying to display the ArrayBuffer inside a canvas I get a scrambled looking image, I might be missing something but it seems that JPEG files are not supported? Or am I missing something...

@ViewChild('canvas') canvasRef: ElementRef;

...

if (typeof Photos !== "undefined") {

  Photos.photos(
    function (photos) {

        console.log("Grabbing: " + photos[0].id);

        Photos.thumbnail(photos[0].id,

          function (data) {

            var canvas = self.canvasRef.nativeElement;
            var ctx = canvas.getContext('2d');

            var imgData = ctx.createImageData(120, 120);
            imgData.data.set(new Uint8Array(data));

            ctx.putImageData(imgData, 0, 0);

          }, function (error) { });
          
    }, function (error) { }

  );

}
@domax
Copy link
Owner

domax commented Nov 17, 2016

Hmm.. I thought any kind of image data may be drawn into canvas. If it is really not supported, then I'd propose whether to use dataurl for image or save it as a file and open and draw it using file url (saving as a file feature is on my schedule, but it will be just dependency to cordova-plugin-file and JS only code).

I didn't plan to provide different content types for thumbnails, but if it is really needed, I may schedule such a feature (e.g. make thumbnail as PNG ArrayBuffer), but I cannot commit to any terms for now :(.

@domax
Copy link
Owner

domax commented Nov 17, 2016

BTW - looks like https://github.com/notmasteryet/jpgjs works fine for JPEGs - try to use it.

domax added a commit that referenced this issue Nov 17, 2016
@domax
Copy link
Owner

domax commented Nov 17, 2016

OK, I updated README with info about JPEG decoder, so I believe it should be a solution.
I don't want to make an explicit dependency to jpgjs stuff, b/c it is optional for this plugin.

@dnmd : I would really appreciate if you confirm that jpgjs works, and if you provide code snippet for that - I'll include it in README.

@domax domax added the wontfix label Nov 17, 2016
@domax domax self-assigned this Dec 8, 2016
@domax domax closed this as completed in 6d2e7e0 Dec 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants