bufferedimage

Jpanel resize on repaint

人走茶凉 提交于 2020-01-09 08:17:49
问题 i am having a scaling operation performed in the below code. The two sliders in the form are X and Y parameters for an scaling affine transformation. My ask here is when i change the slider the image is getting scaled, how do i dynamically resize my jpanel in which this image is getting painted. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package newpackage; import java.awt.Graphics; import java.awt.Image; import java.awt.geom

Java BufferedImage works in appletviewer but not browser

拟墨画扇 提交于 2020-01-06 14:07:55
问题 I'm new Java and I have an applet project to do for school which is all done. It works fine when I run it through the the appletviewer command line but when I preview it through the browser, the images do not show. To make this short, my application must display a map of Canada and have a button for each of the provinces. Whenever a province is clicked, it must show that the province is selected in the map, show the province name and capital's name. I draw the map image in a JPanel. Like I

With BufferedImages, when creating a WritableRaster how do you ensure that it will be compatible with the specific ColorModel?

北城余情 提交于 2020-01-06 02:33:08
问题 I'm learning to use BufferedImages in java, and am trying to create an animation where each frame of the animation is the result of mathematically fiddling around with pixel data. I'm just playing around really. Originally I was using an indexed ColorModel, but I've changed it (to take advantage of more colors) to a direct ColorModel. But now an error crops up saying - Raster sun.awt.image.SunWritableRaster@29c204 is incompatible with ColorModel DirectColorModel: rmask=ff0000 gmask=ff00 bmask

Save a GIF with index transparency using ImageIO out of an image with alpha transparency

怎甘沉沦 提交于 2020-01-05 07:04:17
问题 I have a BufferedImage with alpha transparency, which I need to save as GIF with index transparency. There are no semi-opague pixels, therefore a conversion should be possible. Using the code found under http://gman.eichberger.de/2007/07/transparent-gifs-in-java.html, I define a transparency color (green, for instance, which is not part of the current image) and make it transparent. Works fine, BUT it mixes up the color table and all the colors look awful (although I only use 3 different

A simple way to setting a bufferedImage into a single colored pixel without placing a image into it?

孤人 提交于 2020-01-05 04:43:24
问题 So I just want to set a buffered image into a single background color is there a way to do this? 回答1: Do you mean fill a BufferedImage with a background color? If so, here is an example on how to perform this: import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class TestBufferedImage { private BufferedImage buffer; protected

Load image without autoscaling in Android

Deadly 提交于 2020-01-04 13:12:03
问题 I'm trying to create a map for a game through an image, where each black pixel is equivalent to a wall, and yellow to flowers(1) and green grass(0) so far i had this image (50x50): http://i.imgur.com/Ydj9Cp2.png the problem here seems to be that, when i read the image on my code, it get's scaled up to 100x100, even tough i have it on the raw folder. I can't let it scale up or down because that will put noise and blur on the image and then the map won't be readable. here i have my code: (...)

storing transformed BufferedImage in Java

萝らか妹 提交于 2020-01-04 06:48:49
问题 In Java, instead of using photoshop to transform my images(that I use in the program), I want to use code to transform and save them. I have created an AffineTransform object "at" and called the rotate() method. I have a BufferedImage called "image". I can draw the image on the screen with the desired transformation with this code: g2d.drawImage(image, at, null); What I want to do is to store the combination of at and image in a new BufferedImage image2. How can I do this so that g2d

how to use clip to reduce paint time?

走远了吗. 提交于 2020-01-03 21:02:58
问题 i am trying to use clip to reduce the cpu load. but the clip leaves some garbage on the screen that i can not seem to get rid of. also, turning clipping on and off seems to have no effect on the cpu load. in either case. most of the time seems to be spent in the repaint manager and paint buffered image. import static java.lang.Math.*; import static java.awt.Color.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.image.*; import java.lang.reflect

how to use clip to reduce paint time?

我怕爱的太早我们不能终老 提交于 2020-01-03 21:02:54
问题 i am trying to use clip to reduce the cpu load. but the clip leaves some garbage on the screen that i can not seem to get rid of. also, turning clipping on and off seems to have no effect on the cpu load. in either case. most of the time seems to be spent in the repaint manager and paint buffered image. import static java.lang.Math.*; import static java.awt.Color.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.image.*; import java.lang.reflect

Using java.awt.image.BufferedImage for creating BIFF8 BITMAP record takes much time - Is there any better approach?

≡放荡痞女 提交于 2020-01-03 17:12:38
问题 So I am creating a HSSFSheet having a background bitmap set using apache poi and own low level code. The https://www.openoffice.org/sc/excelfileformat.pdf declares for the Record BITMAP, BIFF8 : Pixel data (array of height lines of the bitmap, from bottom line to top line, see below) ... In each line all pixels are written from left to right. Each pixel is stored as 3-byte array: the red, green, and blue component of the colour of the pixel, in this order. The size of each line is aligned to