Java programming part 97 Graphics : Java Image Manipulation 5

Veröffentlicht am: 07 Juli 2012
auf dem Kanal: Redemptie
4,059
7

Java Programming tutorial, GUI, Graphical User Interface. this tutorial is teaching. How to use Java graphics for drawing, Images, for graphics interfaces and games,Showing you how to manipulate the image, by making the image face in the opposite direction, and sit upside down ect.

// GraphicsTut.java classbelow and below that BGround.java class


import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.*;


public class GraphicsTut extends JFrame{
Image image;
Image image2;
int x1,y1,x2,y2;
BKGround bkg = new BKGround();


public GraphicsTut(){
this.setTitle("Remember g for Graphics");
this.setSize(450,350);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
this.add(bkg);


}
public void paint(Graphics g){

}

public static void main(String[] args){
new GraphicsTut();

}

}

// below BKGround.java class


import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JPanel;


public class BKGround extends JPanel{

Image image;
Image image2;
int x1,y1,x2,y2;

public BKGround(){
ImageIcon I = new ImageIcon("image/Abstract-background-1.png");
image = I.getImage();
ImageIcon I2 = new ImageIcon("image/madBoySprite.png");
image2 = I2.getImage();;


}

public void paint(Graphics g){
x1 = 200;
y1 = 200;
x2 = 100;
y2 = 100;
ImageIcon i = new ImageIcon("image/Abstract-background-1.png");
image = i.getImage();
g.drawImage(image, 0, 0, null);
g.setColor(Color.BLACK);
g.drawRect(40, 40, 30, 30);
g.setColor(Color.RED);
g.drawOval(80, 80, 30, 30);
g.fillArc(140, 140, 30, 30, 180, 10);
g.drawLine(100, 300, 350, 400);
g.setFont(new Font("Arial",Font.BOLD,34));
g.drawString("Paint this!", 150, 100);


ImageIcon i2 = new ImageIcon("image/charcustomsheet.gif");
image2 = i2.getImage();
//g.drawImage(image2, 100, 200, null);
g.drawImage(image2, x1, y1, x2, y2, 40, 60, 80, 120,Color.GREEN, null);
g.drawImage(image2, 250, 250, 50, 50, null);
repaint();
}
}


Auf dieser Seite können Sie das Online-Video Java programming part 97 Graphics : Java Image Manipulation 5 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Redemptie 07 Juli 2012 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 4,059 Mal angesehen und es wurde von 7 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!