devgeeks/Canvas2ImagePlugin

Canvas Image saved with black background

Closed this issue · 10 comments

First of all thanks a lot for the great work and your plugin. I have been able to use it successfully with my Phonegap 2.2 iOS project. The only issue I am facing is that the Canvas image is saved with a black background. Is there anyway to get a white background? My application is a Canvas Paint program and hence I need to save the image in a white background color. Please help me out.
I had one more doubt. How do I get the saved image path? I need to email the image using EMailComposer plugin.
Thanks in advance.
Joseph

Yeah, this is what it looks like in the iOS Photo library when the image has transparent bits...

If you want a white background, you will need to start the canvas with a white background color for them to paint on.

Thanks a lot. I will give it a try. Should solve the problem.
Also if you don't mind, can you give me a hint of how to get the saved image path. I can work around from there.

Thanks once again.

The saved image path? In iOS images in the photo library are not really saved to a path... they are in a db of sorts, IIRC.

If you mean the image I create before saving it, I create a data object directly from the base64 data I get from the canvas object...

No, I understand how you got the base64 data of the Canvas using toDataURL(). After that you save the base64 data in the form of a image in the iOS Camera Roll. I was just curious about the path where this image is actually stored on the device. Is there any folder or the memory location where it is stored, something like this - file://localhost/var/mobile/Applications/946FDEC2-E166-4209-94F8-5E2C70EEDA71/tmp/cdv_photo_010.jpg. I am not very sure and I just copied this after I searched similar threads in StackOverflow. This path then can be passed onto the EmailComposer plugin as attachment, which I will work around. I am sorry to have bothered you so much, but I am a layman when it comes to iOS Phonegap development.
Thanks once again.

ahh...

That path you mention is the one say in your app if you take a pic with the camera... saving to the photo library involves a database instead and the closest you can get to a path is an "asset path" that looks a bit like: assets-library://asset/asset.JPG?id=911F442F-9C8E-4B49-97BF-3103E0A464C3&ext=JPG

This can only be accessed using native libs...

:/

Yes, I am getting that kind of a path from the assetURL. Let's see how far I can go. Thanks for sharing that. At least now I know that the path I was getting is actually somewhat correct. And to let you know, I am able to save the Canvas .png image with a white background now.
Thanks a lot once again.

Good luck!

May God help me !! :(

Thanks.

@jsphkhan could you please share the snippet for converting transparent to white background in cordova canvas.

I also need this solution if you can provide ... thanks in advance.