• Post Reply Bookmark Topic Watch Topic
  • New Topic

error by encode->decode JPEG  RSS feed

Alexander Rubinov
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a function that encode and immediatelly decode the same JPEG-data.
There are (not all) a image that will be black after redecode.
Function is running in multithread environment.
source code:
static public byte[] decode_encode_jpeg( byte[] source ) throws IOException
ByteArrayOutputStream os = null;
Image image = new ImageIcon( source ).getImage() ;
int width = image.getWidth(null);
int height = image.getHeight(null);
Dimension d = new Dimension(width,height);
BufferedImage bufferedImg = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
Graphics2D g2 = bufferedImg.createGraphics();
g2.drawImage(image, null, null);
os = new ByteArrayOutputStream();
JPEGImageEncoder jpegImgEncoder = JPEGCodec.createJPEGEncoder( os );
return os.toByteArray();
try{ if( os != null ) os.close(); } catch( Exception e ){};
Is JPEGImageEncoder threadesave ? when yes, what is the problem?
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!