Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Streaming byte[ ] to image file using file connection

 
Mocky Johnson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,

**Please note i am testing out the application using WTK 2.2 as i do not have a phone to test on.


i am a student doing a project for my final yr. The application requires me to edit an image and save it in another file name, for example: newimage.png. I used the fileconnection from jsr75 and upon editing the image i dataoutputstream it to the file(newImage.png)... after the bytes are streamed to the file, i try to open it using my image editors in my computer but the file cannot be read... when i open the image file, using photoeditor or paint i get the error "cannot determine type". What can i do to view the image.

I am really in need of help... i am stuck can anyone suggest me ideas ? Thanks. Your help will be very much apprieciated. Thank you very much.

Your Sincerely
Mocky
 
Punit Raizada
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a thought ... when u send the image data and re-create the file as a png image ... are u making sure that the header bytes and the row header bytes are part of the new image ???
 
Mocky Johnson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry sir, can u please explain to me what is header bytes and row bytes ? sorry i am new to all this programming. When i stream it out it, the image has been written but the problem is the image editors can't read it... i am really lost... the file size becomes 127kb from 0kb and view the file's properties i see that the image has been just wrote to as the date and time are of that date and time.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot edit an image file without understanding basic concepts like header bytes and row bytes. You need to read the spec for the PNG file format to understand how it organize the bytes in an image.

Your program probably wrote out the image data in the wrong format (i.e., not compliant to the PNG spec).
[ September 17, 2004: Message edited by: Michael Yuan ]
 
Mocky Johnson
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok sir is there any websites or sources where i can read about the png image specs ?
 
Punit Raizada
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the best resource... you can navigate from here

LibPNG

I do not know if anyone actually has java source code available on their website that would create or read PNG images.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic