Changing resolution of snapshot taken
Hi,
I am developing a camera application which I want to run on Nokia 3110 also, a 3rd edition phone. When I call getSnapshot() method of VideoControl class it only works with the 'null' parameter and gives 120x160 default resolution in the obtained image. But I want to change the resolution to 480x640 and others. For that when I used "encoding=image/png&width=480&height=640" it throws a null pointer exception. Does anyone has any idea where am I going wrong and how to obtain a different resolution than 120x160 ?
Please help!!!
Re: Changing resolution of snapshot taken
Hi cryptyritu,
There is some information here and links within that may help you to go on:
[url]http://stackoverflow.com/questions/241882/full-resolution-camera-access-in-j2me[/url]
It handles a similar case.
Best Regards,
Re: Changing resolution of snapshot taken
Hi Maveric,
Thanks for the link :) But I had already gone through that post. May be I have not mentioned properly, but I have used that line of code videoControl.getSnapshot("encoding=png&width=240&height=320"); in my source code. When I run it in my emulator and on phone it gives an alert "Application error" and "Null pointer exception" . And when I use videoControl.getSnapshot(null); then application runs properly.
Please help!
Thanks,
Re: Changing resolution of snapshot taken
Ritu,
When you pass null to getSnapshot method, it means it will return png image and its default resolution is 120x160 in most of the cases.
Resolution can be changed programmatically but for other image types and up to certain limit to which a camera can handle. It may vary devices to device.
I have doubt on the below code which you are using as an argument to getSnapshot method –
getSnapshot(“encoding=image/png&width=480&height=640”);
Above code may cause the problem because you are setting image type as png to which default resolution is 120x160 and I think it can’t be changed.
If your device support jpg images (I think it should support), try using the below code –
getSnapshot("encoding=image/jpg&width=480&height=640");
I think it should work in your case and should handle the given resolution.
To know the supported image types by your device use the below code –
String imgTypes = System.getProperty("video.snapshot.encodings");
System.out.println("imgae types = " +imgTypes);
Thanks,
Somendra Singh
Re: Changing resolution of snapshot taken
Hi Somendra,
Indeed we cannot change png format resolution in Nokia 3110. But we can change for jpeg images upto 480x640 (excluding). After that it gives "Out of Memory exception". Thanks a lot for the solution.
Cheers!
Ritu Raj
Re: Changing resolution of snapshot taken
Out of Memory exception is due to the shortage of the heap memory (runtime memory) in you device. As you must be creating the image from the image byte array returned by the getSnapshot method with the resolution as you stated. Image.CreateImage consumes plenty of heap memory and in your case the device in question is unable to handle this much of memory in run time hence out of memory exception.
Regards,
Somendra
Re: Changing resolution of snapshot taken
Okay,
thanks for the info Somendra.
Regards,
Ritu Raj