- जावा/Grails में एक BufferedImage में फ़ाइल से छवियों को पढ़ने का सबसे तेज़ तरीका क्या है?
- BufferedImage से छवियों को जावा/Grails में एक फ़ाइल में लिखने का सबसे तेज़ तरीका क्या है?
मेरी संस्करण (पढ़ें):एक फ़ाइल से छवियों को पढ़ने/लिखने का सबसे तेज़ तरीका BufferedImage में?
byte [] imageByteArray = new File(basePath+imageSource).readBytes()
InputStream inStream = new ByteArrayInputStream(imageByteArray)
BufferedImage bufferedImage = ImageIO.read(inStream)
मेरी संस्करण (लिख):
BufferedImage bufferedImage = // some image
def fullPath = // image page + file name
byte [] currentImage
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bufferedImage, "jpg", baos);
baos.flush();
currentImage = baos.toByteArray();
baos.close();
}catch(IOException e){
System.out.println(e.getMessage());
}
}
def newFile = new FileOutputStream(fullPath)
newFile.write(currentImage)
newFile.close()
मैंने पढ़ा है कि जावा टूलकिट पढ़ने के लिए बहुत तेज़ है, क्या यह सच नहीं है? यदि यह सच है तो क्या आप अपना जवाब संशोधित कर सकते हैं? –
@ stephan1001 मुझे खेद है, मैं यूआई से संबंधित पैकेज से परिचित नहीं हूं। –
फ़ाइलें और पथ का पूरा पैकेज क्या है? –