Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with ImageIO.write

 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to load an image from a JPG file draw some text with a program and create a file with the image and the text. This is my test class:

The file test.jpg contains the same image as Ejemplo.jpg but it doesn't show the text. I haven't been able to find out what is wrong or what else should be done.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run the code, I get an exact replica of the input image *with* the text overlaid.
 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I jared the program and still no text. the question then is what is wrong with my environment? I am using MyEclipse 8.6.1 and Java 1.6 in a Windows computer.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it still happen if you delete the output file first and close whatever program you're using to view it, or -even better- create an output file with a different name?
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um, how big is Ejemplo.jpg' (in pixels)?
 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf for your support. I just used a new, in-existing file, with the jar file and got the same results. I was viewing the file with Picassa as windows default and closing it every time. Latest I opened the file with Windows Paint. It appear drawing to the graphics is not working in my computer, but I tested it. When I type and display in a JPanel; drawing text in paintComponent() displays the text in the window. However printing the Jpanel with the text that displays in the window doesn't show the text, although printing with paint() should be using paintComponent(). I use

I am mystified.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D:\\test.jpg
D:\\Ejemplo.jpg

How are the files name on your disk. Do they end in upper case JPG or jpeg by any chance?
 
Alejandro Barrero
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The files are exactly D:\\test.jpg and D:\\Ejemplo.jpg.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic