When trying to get image byte data I get null using this method: (any
thoughts?)
Image image = ImagesServiceFactory.makeImageFromBlob(blobKey);
Byte[] bytes = image.getImageData(); // this doesn't work as expected.
It would be nice to fix that method to give whats expected. In my opinion
the image api is thin and could use some enhancements to make it more
useable. I'd like to see it become more like image magick api or GD2 linux
api. Also to note, I'd like to see it have a method to stick the image into
a the blob store with a method call.
My Work around:
private byte[] getImageBytes(BlobData blobData) {
long endIndex = 1024;
long startIndex = 0;
BlobKey blobKey = new BlobKey(blobData.getKey());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
if (endIndex > blobData.getSize()) {
endIndex = blobData.getSize();
}
while (endIndex <= blobData.getSize()) {
byte[] b = blobstoreService.fetchData(blobKey, startIndex, endIndex);
try {
stream.write(b);
} catch (IOException e) {
e.printStackTrace();
}
startIndex = startIndex + 1024;
endIndex = endIndex + 1024;
if (endIndex > blobData.getSize()) {
endIndex = blobData.getSize();
}
if (startIndex > endIndex) {
break;
}
}
byte[] r = stream.toByteArray();
return r;
}
Issue -> http://code.google.com/p/googleappengine/issues/detail?id=4757
Brandon Donnelson
http://gwt-examples.googlecode.com
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.