Serializing BufferedImage with keeping transparency
Hi,
I serialize BufferedImage by using this class:
public class ServerUserAvatarMessage extends ServerMessage {
private static final long serialVersionUID = 6796478081410599600L;
private boolean success = false;
private boolean useDefaultAvatar = true;
private String username = null;
int width; int height; int[] pixels;
public void setAvatar(BufferedImage bi) {
width = bi.getWidth();
height = bi.getHeight();
pixels = new int[width * height];
int[] tmp = bi.getRGB(0, 0, width, height, pixels, 0, width);
}
/**
* @return the avatar
*/
public BufferedImage getAvatar() {
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
bi.setRGB(0, 0, width, height, pixels, 0, width);
return bi;
}
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* @param username the username to set
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the success
*/
public boolean isSuccess() {
return success;
}
/**
* @param success the success to set
*/
public void setSuccess(boolean success) {
this.success = success;
}
/**
* @return the useDefaultAvatar
*/
public boolean isUseDefaultAvatar() {
return useDefaultAvatar;
}
/**
* @param useDefaultAvatar the useDefaultAvatar to set
*/
public void setUseDefaultAvatar(boolean useDefaultAvatar) {
this.useDefaultAvatar = useDefaultAvatar;
}
}
But if i send png files using transparency, transparency is not displayed by the output file. :(