Java programming part 97 Graphics : Java Image Manipulation 5

Publié le: 07 juillet 2012
sur la chaîne: 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();
}
}


Sur cette page du site, vous pouvez voir la vidéo en ligne Java programming part 97 Graphics : Java Image Manipulation 5 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Redemptie 07 juillet 2012, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 4,059 fois et il a aimé 7 téléspectateurs. Bon visionnage!