特效 Java Swing Graphics 获取组件图片 图片旋转

1 篇文章 0 订阅
1 篇文章 0 订阅
下面为所做动画的部分代码,记录以防忘记//截取组件自身图片BufferedImage controlImage = new BufferedImage(bgLayered.getWidth(), bgLayered.getHeight(),BufferedImage.TYPE_INT_ARGB);panel.paint(controlImage.getGraphics());//绘制public void paint(Graphics g) { Graphics2D g2d = (Graphics2D)g.create(); //旋转进场,从无到有,从90度的到正常的 if(rotate){//得到逆转90的图片g2d.translate(-rotateImage.getWidth(), this.getHeight()-rotateImage.getHeight());//平移至指标g2d.rotate(theta,rotateImage.getWidth(),rotateImage.getHeight());g2d.drawImage(rotateImage,0,0, this); }else if(rotateFlgExit){ //退场g2d.rotate(theta,0,rotateImage.getHeight());g2d.drawImage(rotateImage,0,0, null); }else if(scaleRotateFlg){ //绕中心旋转 g2d.translate(this.getWidth()/2, this.getHeight()/2);g2d.rotate(theta);g2d.scale(scale,scale);g2d.drawImage(rotateImage,-this.getWidth()/2, -this.getHeight()/2,null); } else{ super.paint(g); } }//把图片左旋90度对应的方法 public BufferedImage rotate90SX(BufferedImage bi){ int width = bi.getWidth(); int height = bi.getHeight(); BufferedImage biFlip = new BufferedImage(height, width, bi.getType()); for(int i=0; i<width; i++) for(int j=0; j<height; j++) biFlip.setRGB(j, width-1-i, bi.getRGB(i, j)); return biFlip;}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值