⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rot90.java

📁 这个出色的小程序可以把你的网站上的链接
💻 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 + -