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

BufferedImage(s)

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo everyone. I'm just a newbe so please be patient .
I've a problem. I write Graphics Editor and I use BufferedImages as layers. I'd like to save a couple of BufferedImages' objects in one file. Moreover I'd like to move one BufferdImage object to another one - layers' integration.
Any ideas?
Thanks in advance.
 
Maneesh Godbole
Saloon Keeper
Posts: 11090
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lukas,
Welcome to the Ranch.

Check out ImageIO#write to save your images.
How are you rendering your layers? Do all the layers share the same graphics object?
You might find this useful
http://blog.elevenworks.com/?p=2
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean something like that:


I have an array of BufferedImages an I'd like to put them together on one BufferedImage object and save it to file.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noone knows?
 
Maneesh Godbole
Saloon Keeper
Posts: 11090
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check out the link I posted?
It shows how to have multiple layers in one image. Does it help?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't find anything about layers
 
Maneesh Godbole
Saloon Keeper
Posts: 11090
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a link in there where you can download the source code.
Download and study the source code, especially the paintComponent()
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I've studied it. Unfortunately I haven't found the answer. The author uses similar way to mine with showing BufferdImage object, but he has only one BufferedImage object, he invokes createGraphics() on it and he gets the context to draw. Then he invokes g2.drawImage to show the object.
I can invoke g2.drawImage inside the "for loop" to show a few of BufferedImage's objects. It's OK, but the problem is when I want to save those objects to one JPG or PNG file. The static method of ImageIO takes only one BufferedImage object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic