?? rot90.java
字號:
package ru.sakva.bsh;
import java.awt.*;
import java.awt.image.*;
/** Rotate image on +90 or -90 degrees */
public class Rot90 extends ImageFilter
/* * */ {
int width;
int height;
int[] p;
ColorModel colorModel = ColorModel.getRGBdefault();
public boolean clockwise=true;
public boolean asIs=true;
public int back = 0xff000000;
public int front = 0xfffffff;
public void setDimensions(int w,int h)
{
width=h; height=w;
p=new int[width*height];
consumer.setDimensions(width,height);
}
public void imageComplete(int status)
{
if(status != IMAGEERROR && status != IMAGEABORTED)
{
if(p != null)
{
consumer.setPixels(0,0,width,height,colorModel,p,0,width);
}
}
consumer.imageComplete(status);
}
public void setPixels
(int x,int y,int w,int h,ColorModel model,byte[] pixels,int off,int ssz)
{
int i,j,si,di;
j=0; while(j < h)
{
si=off+ssz*j+x;
i=0; while(i < w)
{
if(clockwise)di=width*(height-x-i-1)+(y+j);
else di=width*(x+i)+(width-y-j-1);
p[di]=model.getRGB(pixels[si++]&0xff);
i++;
}
j++;
}
}
public void setPixels
(int x,int y,int w,int h,ColorModel model,int[] pixels,int off,int ssz)
{
int i,j,si,di,c;
j=0; while(j < h)
{
si=off+ssz*j+x;
i=0; while(i < w)
{
if(clockwise)di=width*(height-x-i-1)+(y+j);
else di=width*(x+i)+(width-y-j-1);
c=model.getRGB(pixels[si++]);
if(asIs)p[di]=c;
else
{
if(c==0xff000000)p[di]=back; else p[di]=front;
}
i++;
}
j++;
}
}
public void setColorModel(ColorModel cm)
{ consumer.setColorModel(colorModel); }
/*
public ImageFilter getFilterInstance(ImageConsumer ic){ return this; }
public void resendTopDownLeftRight(ImageProducer ip){ }
public void setHints(int hints){ }
public void setProperties(Hashtable props){ }
*/
/* * */ }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -