帮忙啊,在线等

来源:百度知道 编辑:UC知道 时间:2024/06/05 06:14:37
You should create a new method, swapRGB() for the Picture class. To do this,
you add the method to the file Picture.java.
The swapRGB() method should do the following. For each pixel in the image,
record the values for the red, green and blue color components for that pixel. Then
change them as follows.
* Assign the old red value as the new green value.
* Assign the old green value as the new blue value.
* Assign the old blue value as the new red value.

中文是:要建立一个swapRGB() method ,把照片原来是红的变成绿的,原来绿的变成蓝的,原来蓝的变成红的。

我是新手不会,所以希望高手帮帮忙啊,给个具体点得程序啊
答案都不行啊

我给你一个可以改变颜色的程序 因为我不知道你的图片是什么
你看下这个程序可以解决你的问题的:
import java.awt.*;
import java.awt.event.*;
public class Changcolor {
Frame f;
Button red;
Button blue;
Button yellow;
Panel a1;
public static void main(String[] args) {
Changcolor cl=new Changcolor();
cl.go();
}
public void go(){
f=new Frame("基本GUI编程");
a1=new Panel(new FlowLayout());
f.add(a1);
red=new Button("红色");
a1.add(red);
Myredcolor a=new Myredcolor();
red.addActionListener(a);
blue=new Button("蓝色");
a1.add(blue);
Mybluecolor b=new Mybluecolor();
blue.addActionListener(b);
yellow=new Button("黄色");
a1.add(yellow);
Myyellowcolor c=new Myyellowcolor();
yellow.addActionListener(c);
f.setSize(300,300);
f.setVisible(true);
}
public void redC