Java transforming BufferedImage “Subimage” defined by 4 Points [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-17 05:08:55

问题


I've been doing some work on my school project and came to the point where i need help again :) I've been researching about transforming images in Java, but i haven't really found any useful information in terms of that. I have found this article but since I don't know much python i wasn't able to get what they are doing. I'd like to do pretty much the same thing, but in Java. Is there any method that does that for you or do you need some advanced math for it?

Also additionally, i'd like to keep the aspect ratio of the part of image the same as in real life.

EDIT: The points must be of any shape.

EDIT No2: Also, i'd like to know how to get a subimage of any shape out of a Buffered image. And about the comment that answers a part of a problem... I need my program to do just the same thing reverse way... is there any way of calculating the perpendicular aspect ratio of the image?

If you need any additionall info to answer me this, please ask me in the comments below, since i don't have idea how i would do that.


回答1:


This might be what you are looking for

https://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html#getSubimage(int,%20int,%20int,%20int)

You'll can just measure the width and the height of you original image and multiply by a common factor



来源:https://stackoverflow.com/questions/34954955/java-transforming-bufferedimage-subimage-defined-by-4-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!