• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image Processing

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir/Madam,

Firstly, I am sorry if the thread ( my post ) already exist,if so kindly refer me that post. I have searched already about my problem but i could not find solution.

Secondly, i describe about my problem here.
i have to read a image ( which is stored in binary format) from server ( php - xampp) . i am using Applet to read image (binary file) from server and i have to convert into original image then i have to take print out.

Kindly help me out. Thanks in advance.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

The ImageIO class can be used to convert binary data into BufferedImage objects. You can then display these in your user interface; either with custom painting or with an ImageIcon.
 
subash prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,

Thank you for your reply. A image file has been converted into binary ( for security purpose, image will not be sent directly to client(applet) so that image has been converted into binary format ). My applet will listen or by sending request, it will read binary image format file in stream and keep it in applet.

Then i have to convert this binary image file into ordinary .jpg file and take printout.

Hope i explained my problem clearly.

Could you please help me how to solve this problem....i am in need.
Thanks in advance.
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you convert the image to "binary"?
 
subash prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,

With the above problem , first i started to convert the image into binary (1 | 0 ).
Could you please whether i am using correct way to change image to binary , if so please tell me what to do next to convert binary to ordinary image again.

 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please UseCodeTags next time? It makes your code so much easier to read.


By reading it as an image, then storing it as an image again the quality of the image may become less. It's probably better to open a connection to the URL and copy the bytes into the ByteArrayOutputStream directly:


I sugges you give your file a different extension. "bat" is used for Windows / DOS batch scripts. "dat" is much more common for binary data files.


This is where you're logic goes wrong. The binary file will contain only 0 and 1 bytes. That's right, bytes. You've essentially made your file up to 8 times as big, as now it uses 1 byte for each bit (ignoring leading zeros).

Usually I'd say to use the original file directly, but you don't want to do this because of security concerns. That means that you have to encrypt the file, then decrypt the file again before you convert the file back to an image. You have a crude way of encrypting, but you don't decrypt it back.

Now you use your own, very simplistic encryption. I would take a look at CipherOutputStream and CipherInputStream instead, with a secure encryption algorithm like AES or Blowfish. The advantage is that it adds even more security (you need a key to decrypt), but it also doesn't make your file up to 8 times as big.

If you still want to use your own encryption technique, you should improve it. Make sure that each byte is stored in 8 bytes, not make it dependent on the value. So do not use Integer.toBinaryString(by) but use bit-wise operations:
The decrypting, using a DataInputStream wrapped around the InputStream so you can use the readFully method:
 
subash prasanna
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this code right?(i am new to java ) . It shows error that java.io.EOFException at last, and in generated bin file, there are nul values. what would be the problem

 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're now trying to decrypt the original image file while you should be decrypting the binary data file you just wrote.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Where do I get the decrypted file?

My code is:



Thanks:
Ramakrishna K.C
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Where do I get the decrypted file?


What do you mean by this? The earlier posts deal with encrypting and decrypting an image. How does your problem relate to the thread?
 
Ranch Hand
Posts: 507
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe you should not use the word "Image Processing". "Image Processing" is a complete subject, where 90% of the stuff has to be done via C++ and C.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"Image Processing" is a complete subject, where 90% of the stuff has to be done via C++ and C.


Not sure what you mean by "complete subject", but there's nothing in image processing that can't (and isn't) being done in Java.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic