bufferedimage

Pink/Reddish tint while resizing jpeg images using java thumbnailator or imgscalr

爱⌒轻易说出口 提交于 2019-12-18 06:12:37
问题 I am trying to convert an image (url below) using two libraries (thumbnailator and imgscalr. My code works on most of the images except a few which after conversion have a pink/reddish tint. I am trying to understand the cause and would welcome any recommendation. Note - Image type of this image is 5 i.e BufferedImage.TYPE_3BYTE_BGR and i am using Java 7 Using Thumbnailator Thumbnails.of(fromDir.listFiles()) .size(thumbnailWidth, thumbnailHeight) .toFiles(Rename.SUFFIX_HYPHEN_THUMBNAIL);

Byte array to buffered image conversion slow

淺唱寂寞╮ 提交于 2019-12-18 05:55:41
问题 I have a simple server-side code that receives a byte array representing an image in JPEG format and returns the dimensions of the image. public String processImage(byte[] data) { long startTime = System.currentTimeMillis(); ByteArrayInputStream stream = new ByteArrayInputStream(data); BufferedImage bufferedImage; bufferedImage = ImageIO.read(stream); int height = bufferedImage.getHeight(); int width = bufferedImage.getWidth(); long endTime = System.currentTimeMillis(); return "height="

How to save file using JFileChooser?

不羁岁月 提交于 2019-12-18 04:37:28
问题 I have a method in my application called "Save as" which Saves the image of my application on computer my into a file. I used the JFileChooser to let the users choose their desired location for saving the file. The problem is unless user explicitly types in the file format, it saves the file with no extension. How can I have formats like jpg, png in the File Type drop down menu. and, how can i get extension from the File Type drop menu for saving my image file. ImageIO.write(image,extension

Painting in a BufferedImage inside Swing

落花浮王杯 提交于 2019-12-18 04:27:06
问题 Im working on a paint application written in java and running into a few (more) problems. I have a gui and a working program(kinda), my only problem is that the lines and graphics that the user draws are not saved(disappear after next one is drawn). From a past question i learned that i will need to use a BufferedImage to store the drawings then paint that inside my paint class. My questions are, Can anyone provide a basic explanation/example of how to use a bufferedimage to store and paint

Converting an ImageIcon to a BufferedImage

左心房为你撑大大i 提交于 2019-12-18 04:08:35
问题 I've been trying to convert a ImageIcon to BufferedImage ... And I've had no luck. I have a pre-existing ImageIcon that needs to be converted to a Buffered Image for the vast amount of BufferedImage operations that exist. I have found a few ways, but all of them are hugely CPU intensive. 回答1: What's wrong with: BufferedImage bi = new BufferedImage( icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB); Graphics g = bi.createGraphics(); // paint the Icon to the BufferedImage.

Create an image from a non-visible AWT Component?

纵饮孤独 提交于 2019-12-18 03:55:14
问题 I'm trying to create an image (screen-shot) of a non-visible AWT component. I can't use the Robot classes' screen capture functionality because the component is not visible on the screen. Trying to use the following code: BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); component.paintAll(g); Works sometimes, but does not work if the component contains things such as a text box or button, or some sort of OpenGL / 3D

.drawLine() issues and buffered image

两盒软妹~` 提交于 2019-12-17 21:28:38
问题 I have a paint programme and i have all the buttons and sliders done however i am having a problem with the actual painting itself. When I drag the cursor across the screen instead of an unbroken line I am getting almost a dotted line which i dont want. Here's the code for the MouseListener in the JPanel and BufferedImage : public void mouseDragged(MouseEvent e) { Graphics g=buffered.getGraphics(); g.setColor(mycol); Graphics2D graph=(Graphics2D)g; BasicStroke stroke=new BasicStroke(30);

Out of memory problem saving large BufferedImage

ぐ巨炮叔叔 提交于 2019-12-17 19:50:43
问题 I have a problem saving large (f.e. 12 000 x 9 000 ) images. I'm developing a graphical editing software ( something like simple Photoshop ) and The user obviously has to have to ability to save the image. Lets say I would like to save the image as .png. Does JAVA always need to use the BufferedImage for saving drawn stuff ? I know the equation for size of the image is: Xsize * Ysize * 4 ( red, green, blue, alpha ) So in this case we get over 400 MB. I know I could save the image in parts (

How to increase the resolution of image in PDF renderer?

孤街浪徒 提交于 2019-12-17 19:50:03
问题 I want to increase the resolution of a image. I used PDFRenderer-0.9.0 jar . It is downloaded from java.net for converting PDF pages to images. I want to Convert 46_2.pdf PDF file to image . The converted 46_2.png image is small with dimensions 612 x 792 [ width x height ] , So I want to increase the image dimensions to 1200 x 1400 [ width x height] . I tried previously PdfBox for converting PDF page into PNG image file. There is a problem only page is converted but text is missing . So I

int array to BufferedImage

淺唱寂寞╮ 提交于 2019-12-17 19:47:17
问题 I'm making with the Robot class a printscreen and I convert the BufferedImage into an int array. Then I want to convert the int array back to a bufferedimage but that gives an error. This is my code: Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); BufferedImage printscreen = robot.createScreenCapture(new Rectangle(screen)); int[] pixels = ((DataBufferInt) printscreen.getRaster().getDataBuffer()).getData(); BufferedImage image = new BufferedImage(screen.width, screen.height,