GWT 客户端图像裁剪和调整大小 [英] GWT client-side image crop and resize

查看:24
本文介绍了GWT 客户端图像裁剪和调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何 GWT 小部件可以让我:

Is there any GWT widget which allows me to:

  • 选择图像的一部分,然后检索选择区域?
  • 调整图像大小,然后给我更新后的大小?

上述内容也应反映在浏览器中.

The above should be reflected in the browser as well.

推荐答案

据我所知,GWT 客户端代码不能直接修改图片,但是可以将 Image 小部件设置为只显示一部分图片.您可以使用 constructor Image(java.lang.String url, int left, int top, int width, int height),其中 widthheight 是可见框的尺寸,而不是图像本身.

As far as I know, GWT client-side code cannot directly modify images, but the Image widget can be set to display only a portion of an image. You can do this using the constructor Image(java.lang.String url, int left, int top, int width, int height), where width and height are the dimensions of the visible box and not the image itself.

但是,这不允许您调整大小然后裁剪.为此,您可以先调整图像大小,然后将其放入绝对面板中进行裁剪.

However this does not allow you to resize and then crop. In order to do this you could first resize the image then put it in an absolute panel to crop it.

AbsolutePanel testPanel = new AbsolutePanel();
Image image = new Image("path/image.jpg");
image.setWidth("1000px");
testPanel.add(image,-100,-100);
testPanel.setPixelSize(300,300);

如果这不是您要找的内容,我深表歉意,但这是我的最佳答案.

I apologize if this isn't exactly what you're looking for, but it's the best answer I have.

这篇关于GWT 客户端图像裁剪和调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆