09-21-2012 03:39 AM
Hello,
I tried using jpegEncoder to save image and used File and FileStream to save that encoded jpeg to playbook.
here's the code that i used.
var storage:File = File.userDirectory.resolvePath("shared/photos/Pain tBook");
if(!storage.exists)
{
storage.createDirectory();
}
var file:File;
do
{
file = File.userDirectory.resolvePath("shared/photos/Pain tBook/Image"+num+".jpeg");
num++;
}while(file.exists)
var bmd:BitmapData = new BitmapData(canvasWidth, canvasHeight);
bmd.draw(stage);
var jpegEncoder:JPEGEncoder = new JPEGEncoder(Quality);
var byteArray:ByteArray = jpegEncoder.encode(bmd);
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeBytes(byteArray);
stream.close();
In some reviews of PaintBook, users says that they are unable to save the image i.e image does not appear under
/shared/photos/PaintBook folder. I tested the code on many playbooks and the code runs fine on them.
I downloaded a sample app from BB github. it has a code as follows
var bitmapData:BitmapData = new BitmapData(1024,600); bitmapData.draw(appInstance.mainMovieClip); var jpegEncoder:JPEGEncoder = new JPEGEncoder(); var byteArray:ByteArray=jpegEncoder.encode(bitmapData); var currentDate:Date = new Date(); var name:File = File.userDirectory.resolvePath(File.documentsDirec tory.resolvePath("Signature-Image"+currentDate.toS tring()+".jpg").nativePath); var file:FileStream = new FileStream(); file.open(name, FileMode.WRITE); file.writeBytes(byteArray); file.close();
The problem is this code does not saves images on my playbook i.e i am unable to see the saved image under any folder. It is a sample app from blackberry that means it should have worked on their playbook
Why is it so that code works on some playbook and not on others. Which directory should i use to save images so it works on all playbook?
09-21-2012 05:04 PM
09-22-2012 02:46 PM
09-22-2012 02:58 PM
09-22-2012 03:02 PM
09-24-2012 12:38 PM
09-25-2012 02:48 AM
09-28-2012 08:57 AM
09-29-2012 12:41 PM
09-29-2012 04:35 PM