| Reply | « Previous Thread | Next Thread » |
|
Is there any way to reduce the byte[] size in which the camera captured image is stored im encoding the byte array in to base64 binary and trying to send it to server.
or else can anyone suggest an alternative to send image to the server |
| mahesh_aquarius |
| View Public Profile |
| Find all posts by mahesh_aquarius |
|
anyone can suggest how to send image to server successfully
|
| mahesh_aquarius |
| View Public Profile |
| Find all posts by mahesh_aquarius |
|
Hi,
Base64 alogrithm is more of a encoding rather than compression. Base64 makes sure that there is no loss of data in between. If you want to reduce the size of images while transferring then one way is to reduce the resolution of the images captured that will automatically reduce the size of the images. Otherwise you may have to implement image compression algorithms such as Run length encoding or Huffman Coding. In implementing the image compression algorithms make sure that the time taken by the algorithm should not be much otherwise it will be of no use I think. Hope this information will help you. Sunil Software Developer - J2ME |
| sunil_bhambani123 |
| View Public Profile |
| Find all posts by sunil_bhambani123 |
|
Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
raj_J2ME
Offline
Forum Nokia Champion
|
|
Hi Mahesh,
Following the suni post you can move forward with the code, FileConnection fc = (FileConnection) Connector.open(”file://localhost/root1/path/to/file”); if (!fc.exists()) { throw new IOException(”File does not exists”); } InputStream fis = fc.openInputStream(); byte[] b = new byte[5000]; int length2 = fis.read(b, 0, 5000); fis.close(); fc.close(); Now to avoid lose of data, we can apply base64 encoding like String tempStr2 = new String(Base64.encode(fileBytes)); Note:- you may useany base64 class for this use but encoding and decoding should be synchronized no matter whatever is implementation technology on server * Now we will build http connection and upload data on it httpConnection = (HttpConnection) Connector.open(”http://Server/Address/to/target/script”); httpConnection.setRequestMethod(HttpConnection.POST); httpConnection.setRequestProperty(”User-Agent”, “Profile/MIDP-2.0 Configuration/CLDC-1.0″); httpConnection.setRequestProperty(”Content-Language”, “en-US”); httpConnection.setRequestProperty(”Content-Type”, “application/x-www-form-urlencoded”); httpConnection.setRequestProperty(”Content-Length”, Integer.toString(data.length)); os = httpConnection.openOutputStream (); os.write(data); os.close(); httpConnection.close(); Thanks, Thanks R a j - The K e r n e l |
|
Hi raj
i tried the same http code but might some prblm in compatibility as our web service is written in .net also tried encoding the image in base 64 binary but in .net the decoded string is not exactly what we wanted thnks |
| mahesh_aquarius |
| View Public Profile |
| Find all posts by mahesh_aquarius |
|
Join Date: Mar 2008
Posts: 2,161
Location: The Capital of I N D I A
raj_J2ME
Offline
Forum Nokia Champion
|
|
Hi Mahesh,
Please discuss the same issue with your server side team,Check wjat they can do for you,in order to solve this issue, Thanks, Thanks R a j - The K e r n e l |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Fast Image Capture | Tobias_80 | Symbian Media (Graphics & Sounds) | 9 | 2007-06-18 13:29 |
| Opening a JPEG Image | ummarbhutta | Mobile Java Media (Graphics & Sounds) | 8 | 2007-02-15 07:34 |
| how can i capture image with a background image | mshouab | Mobile Java Media (Graphics & Sounds) | 3 | 2007-01-23 17:35 |
| how to cut some part of Image | mshouab | Mobile Java Media (Graphics & Sounds) | 2 | 2006-08-04 10:05 |
| Nokia Image Converter | davidpurdie | General Discussion | 0 | 2004-02-18 16:31 |