• Post Reply Bookmark Topic Watch Topic
  • New Topic

display an image from an inputsource

 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
i have to display an image file(in the JFrame or panel),which comes through an inputstream from the database and not from the local drive.how to do it?.
i tried to write the contents of the inputstream to a file and drawImage(file) and it writes to the JFrame.but i just want to know,is there anyway i can directly draw the image from the inputstream.
thanks in advance,
lavanya
 
Dale Mitchell
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Determine image size and create a byte[] to hold it from the stream. Once loaded you can directly create the image by using either creating a new ImageIcon using one of the constructors that take a byte[] or using Toolkit.createImage(byte[] imageData)
 
David G Risner
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, how does one then handle an Image with more than Integer.MAX_VALUE bytes?
 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dale,
thanks,it's working

lavanya
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm... that would mean the Image is around 20 Gigs in size.... I think you would have massive performance problems when dealing with images of this size anyway... I'd think you would split this gigantic image into several smaller images and load only the parts you need...

-Nate
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!