I'm using Signature capture in Mobile App and most of the time it works correct. I have offline capability for the App s o when the App is in offline mode, signature is captured and while sending to the server the image is going as black square.This is due to any data corruption at the mobile level or any issue in using the signature API. Please advise.
Code:
Image sourceImage = sign.getSignatureImage().scaledSmallerRatio(300, 100);
Image mute = Image.createImage(sourceImage.getWidth(), sourceImage.getHeight(), 0xffffffff);
Graphics g = mute.getGraphics();
g.drawImage(sourceImage, 0, 0);
test.setSignature(mute);
Base64.encodeNoNewline(EncodedImage.createFromImage(test.getSignature(),
false).getImageData())
Questions:
New Code leads to white spaces in the signature also. Signature looks like not renderingly properly. Please advise.
What is the code if I have to send the image as PNG to the server. I'm using following code: Base64.encodeNoNewline(EncodedImage.createFromImage(act.getSignature(), false).getImageData())
Make sure you are saving the image file as a PNG and not as a JPEG. The image file might contain transparency and some JPEG encoders might fail in that case.
To make the image "jpegable" (totally made that up right now) you can do the following:
// white mutable image
Image mute = Image.create(sourceImage.getWidth(), sourceImage.getHeight, 0xffffffff);
Graphics g = mute.getGraphics();
g.setAntiAliased(true);
g.drawImage(sourceImage, 0, 0);
Now you can save mute as a JPEG since it's an opaque white image. The black signature will appear correctly on top of that.
User contributions licensed under CC BY-SA 3.0