fixed bug where bytes where being copied incorrectly

This commit is contained in:
Dank074 2019-08-08 18:37:39 -05:00
parent 89add83bcd
commit 4cdfbf0ce6
2 changed files with 5 additions and 3 deletions

View File

@ -55,13 +55,14 @@ public class CameraRoomPictureEvent extends MessageHandler
this.client.getHabbo().getHabboInfo().setPhotoJSON(json); this.client.getHabbo().getHabboInfo().setPhotoJSON(json);
try { try {
BufferedImage theImage = ImageIO.read(new ByteBufInputStream(image));
if(Emulator.getConfig().getInt("ftp.enabled") == 1) { if(Emulator.getConfig().getInt("ftp.enabled") == 1) {
byte[] imageBytes = ((DataBufferByte) theImage.getData().getDataBuffer()).getData(); byte[] imageBytes = new byte[image.readableBytes()];
image.readBytes(imageBytes);
FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.camera") + URL); FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.camera") + URL);
FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.camera") + URL_small); FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.camera") + URL_small);
} }
else { else {
BufferedImage theImage = ImageIO.read(new ByteBufInputStream(image));
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL)); ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL));
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL_small)); ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL_small));
} }

View File

@ -57,7 +57,8 @@ public class CameraRoomThumbnailEvent extends MessageHandler
try { try {
if(Emulator.getConfig().getInt("ftp.enabled") == 1) { if(Emulator.getConfig().getInt("ftp.enabled") == 1) {
byte[] imageBytes = ((DataBufferByte) theImage.getData().getDataBuffer()).getData(); byte[] imageBytes = new byte[image.readableBytes()];
image.readBytes(imageBytes);
FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.thumbnail") + room.getId() + ".png"); FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.thumbnail") + room.getId() + ".png");
} }
else { else {