【正确答案】
int red=(x|y)&0xff;
img=createImage(new MemoryImageSource(w,h,pix,0,w));
g.drawImage(img,0,0,this);
【答案解析】[解析]
本题主要考查Java Applet程序的设计。解答本题的关键是掌握MemoryImageSource(int width,int height,int pixel[],int offset,int scanLineWidth)方法的使用;其中width和height指明图像的大小,pixel中包含每个像素点的值,scanLineWidth指明图像中每行的像素数。在本题中,int red=(x|y)&0xff;语句的功能是定义变量red使其值为(x|y)&0xff,img=createImage(new MemoryImageSource(w,h,pix,0,w));语句的功能是生成图像,g.drawImage(img,0,0,this);语句的功能是在指定的Applet显示区内画出图像。