Quantcast
Channel: web development helpdesk » image
Browsing all 10 articles
Browse latest View live

How do I convert a Java image to a jpeg encoded byte array?

The ImageIO class can be used to write an image as a JPEG encoded stream.If you write that stream to a ByteArrayOutputStream then you will end up with a byte array that contains the JPEG encoded image....

View Article



How do I convert a Java Image to a png byte array?

The ImageIO class can be used to write an image as a PNG encoded stream.If you write that stream to a ByteArrayOutputStream then you will end up with a byte array that contains the PNG encoded image....

View Article

How do I paint a tiled image, for example as a background of a panel?

The TexturePaint class can be used to achieve that. public void paintComponent(Graphics g) { if(paint == null) { try { // Create TexturePaint instance the first time int height = image.getHeight(this);...

View Article

How do I read an image from a byte array in Java?

Create a ByteArrayInputStream from your byte array and then use ImageIO class to read image from that stream. InputStream in = new ByteArrayInputStream(bytearray); BufferedImage image = ImageIO.read(in);

View Article

How can I return an image using a servlet?

Basically you stream the image to the http response stream. Easier to explain with code so here’s a simple example. import java.io.File; import java.io.FileInputStream; import java.io.IOException;...

View Article


How to determine if Image supports alpha?

The PixelGrabber can be used to get a ColorModel instance that has a method to tell if alpha is supported. You just need to load a single pixel from the image to get the ColorModel. PixelGrabber pg =...

View Article

How to convert an Image to a BufferedImage?

// Load the image image = new ImageIcon(image).getImage(); // Determine transparency for BufferedImage // http://helpdesk.objects.com.au/java/how-to-determine-if-image-supports-alpha boolean hasAlpha =...

View Article

How to embed images in HTML mail using JavaMail

Multipart emails can be used to send html content with JavaMail. If you want to use images in the html content you can either specify the url of the image on an external server, or you can embed the...

View Article


Changing the ColorModel of a BufferedImage

Often when doing image processing we need to change the color of the image pixels. This ultimately involves iterating through all the pixels of an image changing values as required. This can be a slow...

View Article


Stop iPhoto or Aperture opening when iPhone plugged in

When you plugin your iPhone (or iPod touch) into your Mac either iPhoto or Aperture get automatically launched. Reason for this is so any photos can be imported from the iPhone to your Mac. You can...

View Article
Browsing all 10 articles
Browse latest View live




Latest Images