KineticJS - 缩放后重新缩放图像/形状(KineticJS - Rescaling images/shapes after zoom)
所以基本上我有一个应用程序,通过缩放每一层并调整图层的位置来放大。 但是我在某些图层上有一堆圆圈(和图像),无论缩放级别如何(无论图层的比例如何),我都需要保持相同的尺寸。
有没有办法在没有迭代的情况下设置图层中每个形状/图像的比例? 我已经看过使用Group但没有通用的方法来设置通用规模。
如果没有,是否有一种有效的方法可以在没有迭代的情况下做到这一点?
So basically I have an application which zooms in by scaling every layer and adjusting the position of the layers. However I have a bunch of circles (and images) on some layers which I need to keep the size the same regardless of the zoom level (ie regardless of the scale of the layer).
Is there a way to set the scale of every shape/image in a layer without iteration? I've looked at using a Group but there is no universal way to set a universal scale.
If not, would there be an efficient way to do this without iteration?
原文:https://stackoverflow.com/questions/20715262
最满意答案
好吧,经过一番挣扎,这就是我解决它的方法。 这就是我在第二个控制器中所做的:
@RequestMapping(value = "/upload", method = RequestMethod.POST) public @ResponseBody ResponseEntity<byte[]> uploadImage(final FileUploadBean fileUploadBean) throws Exception { File file = null; try { final MultiValueMap<String, Object> requestParts = new LinkedMultiValueMap<>(); final String tmpImageFileName = IMAGE_TMP_DIR + fileUploadBean.getFile().getOriginalFilename(); file = new File(tmpImageFileName); fileUploadBean.getFile().transferTo(file); requestParts.add("file", new FileSystemResource(tmpImageFileName)); HttpHeaders headers = new HttpHeaders(); headers.set("Content-Type", "multipart/form-data"); // Sending it like the client-form sends it ResponseEntity<byte[]> response = restTemplate.exchange(ImageUrlUtils.getUploadUrl(), HttpMethod.POST, new HttpEntity<>(requestParts, headers), byte[].class); return new ResponseEntity<>(response.getBody(), response.getStatusCode()); } catch (Exception ex) { return new ResponseEntity<>((ex.getMessage).getBytes("UTF-8"), HttpStatus.INTERNAL_SERVER_ERROR); } finally { if (file != null && file.exists()) { file.delete(); } } }
Well, after some struggling this is how I solved it. That's what I did in the second controller:
@RequestMapping(value = "/upload", method = RequestMethod.POST) public @ResponseBody ResponseEntity<byte[]> uploadImage(final FileUploadBean fileUploadBean) throws Exception { File file = null; try { final MultiValueMap<String, Object> requestParts = new LinkedMultiValueMap<>(); final String tmpImageFileName = IMAGE_TMP_DIR + fileUploadBean.getFile().getOriginalFilename(); file = new File(tmpImageFileName); fileUploadBean.getFile().transferTo(file); requestParts.add("file", new FileSystemResource(tmpImageFileName)); HttpHeaders headers = new HttpHeaders(); headers.set("Content-Type", "multipart/form-data"); // Sending it like the client-form sends it ResponseEntity<byte[]> response = restTemplate.exchange(ImageUrlUtils.getUploadUrl(), HttpMethod.POST, new HttpEntity<>(requestParts, headers), byte[].class); return new ResponseEntity<>(response.getBody(), response.getStatusCode()); } catch (Exception ex) { return new ResponseEntity<>((ex.getMessage).getBytes("UTF-8"), HttpStatus.INTERNAL_SERVER_ERROR); } finally { if (file != null && file.exists()) { file.delete(); } } }
相关问答
更多-
SpringMVC实现文件上传 后台multipartfile接收的文件一直为null;怎么解决[2023-08-01]
你文件上传用的什么方式,如果是submit直接提交的需要给form加一个属性:enctype="multipart/form-data",如果是异步提交则需要看你的上传控件的ID是否正确 -
httpClient 转发请求,传递 MultipartFile[2023-12-28]
先写到服务器本地临时文件,在传给远程服务器吧 -
File file = new File("/Users/aikaliu/document/micrown/source/img/20160802144001791.jpg"); final DiskFileItem diskFileItem = new DiskFileItem("fileData", "text/plain", true, file.getName(), 100000000, file.getParentFile()); InputStream input = nul ...
-
如何使用Spring / MultipartFile捕获中断的流(How to catch an interrupted stream with Spring/MultipartFile)[2023-09-27]
Multipart流已经加载到服务器,然后您可以在控制器中访问它。 使用checksum确保文件不会中断。 计算它并与Multipart数据一起发送: @RequestMapping(...) public ResponseEntity> post(@RequestParam("file") MultipartFile file, @RequestParam("checksum") String checksum) { ... } 之 ... -
事实证明,这非常简单: @RequestMapping(value = "/upload", method = RequestMethod.POST) public ResponseEntity executeByPost(WebRequest webRequest) { MultiValueMap
files = ((StandardMultipartHttpServletRequest) ((ServletWebRequest) webRequest ... -
隧道MultipartFile(Tunneling MultipartFile)[2022-06-12]
好吧,经过一番挣扎,这就是我解决它的方法。 这就是我在第二个控制器中所做的: @RequestMapping(value = "/upload", method = RequestMethod.POST) public @ResponseBody ResponseEntityuploadImage(final FileUploadBean fileUploadBean) throws Exception { File file = null; try { final Mul ... -
我补充说
org.springframework.integration spring-integration-http ${spring.version} -
当您使用multipart您的表单字段将包含在request Stream 。 所以你必须检查它们是否是form fields 。 这是我在servlet中使用的,您可以对其进行适当的更改以在Spring-MVC 。 boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { try { ...
-
如何使用HibernateValidator验证MultipartFile?(How to validate a MultipartFile using HibernateValidator?)[2023-10-21]
现在我明白了你要特别想要完成的事情。 那么你可以实现自己的自定义验证。 例如,不是实现Spring验证器接口,而是为您为此特定情况定义的特定注释实现Hibernate ConstraintValidator 。 检查此链接 。 在这种情况下,您可以为MultipartFile对象的@NotNull验证器添加实现。 Now I understand what you are trying to accomplish specifically. Well you could implement your own ... -
经过一些调查后,我发现只有在Tomcat处理请求时, MultipartFile才存在于临时目录中。 在响应之后它删除文件。 这就是尺寸为零的原因。 可以使用自定义结构将此数据存储在内存中或DB中或其他位置。 这是一个例子: public class UploadedFile { private final String originalFilename; private final byte[] data; public UploadedFile(String fileName, ...