Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.RenderingHints;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.swing.JPanel;
- import rektify.MathUtils.Sector;
- public class ImagePanel extends JPanel{
- private BufferedImage image;
- private Sector sector;
- private boolean isBilinear = false;
- public void loadFromFile(File file) {
- try {
- image = ImageIO.read(file);
- } catch (IOException ex) {
- // ...
- }
- }
- public void setIsBilinear(boolean state) {
- this.isBilinear = state;
- }
- @Override
- public void paintComponent(Graphics g) {
- Graphics2D g2d = (Graphics2D)g;
- if (image != null) {
- // g.drawImage(image, 0, 0, null);
- if (this.isBilinear)
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.drawImage(image, 0, 0, this.getWidth(), this.getHeight(), 0, 0, image.getWidth(), image.getHeight(), null);
- }
- if (sector != null) {
- }
- }
- void setSector(Sector sector) {
- this.sector = sector;
- }
- public BufferedImage getImage() {
- return image;
- }
- public void setImage(BufferedImage im) {
- this.image = im;
- this.repaint();
- }
- }
Add Comment
Please, Sign In to add comment