-2

click here to open image

This is an image captured from a web cam, and save it to an label. no url used. can i get the image from the label and save it to mysql? NOT USING URL

maybe with getIcon() method?

camickr
  • 321,443
  • 19
  • 166
  • 288
  • you could create a column of type BLOB(Binary Large Object), which is designed for this kind of data - this may be helpful http://stackoverflow.com/questions/7052655/insert-blobs-in-mysql-databases-with-php – Japu_D_Cret Mar 24 '17 at 13:00
  • this is not what i want. i know how to save image to mysql. my question is how to get image from label without using url. the label image was an captured by the web cam. – Edgardo Martinez Mar 24 '17 at 13:03

1 Answers1

1

is how to get image from label

You can create a BufferedImage from any Swing component. The basic code is:

BufferedImage image = new BufferedImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
label.paint( g2d );
g2d.dispose();

Or you can check out Screen Image which adds extra features to the above code to make it more flexible. Then you can just use:

BufferedImage image = ScreenImage.createImage( label );
camickr
  • 321,443
  • 19
  • 166
  • 288