This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert Ascii String to Tif file format content

 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I do this?
Thanks
Angela
 
Swapna Mishra
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tiff is an image type. So, what you would need to do is create an .tif image of the text that you have. Java has a package "jai - Java Advanced Imaging API". You could use that.
I had made a class that creates an image stream of tiff type. You could then create a new file and store the image in it.
Here is the class ....
 
Deepak Kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for this program.

if the string is large as shown below, then in the tiff file the below string should be shown as

hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world
hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world

but only few hello world is written to tiff file.
Also can you please let me know if it is possible to format the string as it is and write to tiff file.




thanks a lot
appreciate your help

Thanks,
Deepak
 
Winston Gutkowski
Bartender
Pie
Posts: 10504
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Kumar wrote:if the string is large as shown below, then in the tiff file the below string should be shown as
...
but only few hello world is written to tiff file.

So this is a new requirement. It pays to give us ALL of the information at the start.

Not being an image expert I don't have much else to offer beyond: Why do you need to do this?

Converting text to an image doesn't seem to me like a particularly sensible thing to do, since the resulting image is
likely to be waaay bigger than the original text.

Winston

PS: The lines in your last post are far too long.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Converting text to an image doesn't seem to me like a particularly sensible thing to do, since the resulting image is
likely to be waaay bigger than the original text.

Having implemented the email-address-as-an-image display here on this site I beg to differ; size is unlikely to play a role in this. But I do admire Deepak's confidence that someone who hasn't posted here for 11+ years might still be listening to the conversation

These days one shouldn't use JAI, though, (which is obsolete), and no com.sun.* classes. The javax.image.ImageIO class would be helpful instead.
 
Winston Gutkowski
Bartender
Pie
Posts: 10504
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:But I do admire Deepak's confidence that someone who hasn't posted here for 11+ years might still be listening to the conversation

Dang! I always get caught out by those. Colour me "Doh-h!".

Winston
 
Deepak Kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the response.

able to wrap the test using org.apache.commons.lang.WordUtils;
as shown below.
 
Deepak Kumar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
however with the below image code,





am getting the image background color as BLACK and font color as WHITE on windows server 2008 R2 enterprise, Service pack1, 64 bit OS.

and the same code am getting background color as WHITE and font color as BLACK on windows XP professional, version 2002, servcie pack 3, 32 bit.

am just quoting the machine configuyrations, am not sure if that is the probelm in different colors.
can somebody please let me know what could be the issue?

Thanks,
Deepak


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic