affinetransform

How do I translate parabolically?

倖福魔咒の 提交于 2019-11-28 06:38:56
I'm working on an iPhone app with some simple animation. I have a view I want to translate, but not along a line. I want to translate it parabolically. Imagine that I am animating a car moving along a curved road. I know I can set the transform properly to an instance of CGAffineTransform Problem is, I have no idea how to create the transform. I know how to scale, translate, etc. but how do I translate parabolically? Is it even possible? Brad Larson To animate along a smooth curve, you'll want to use a CAKeyframeAnimation. In this answer I provide code for a combined animation that moves an

Rotating BufferedImage changes its colors

别等时光非礼了梦想. 提交于 2019-11-28 06:25:30
问题 I'm trying to code a class to seam carve images in x and y direction. The x direction is working, and to reduce the y direction I thought about simply rotating the image 90° and run the same code over the already rescaled image (in x direction only) and after that, rotate it back to its initial state. I found something with AffineTransform and tried it. It actually produced a rotated image, but messed up the colors and I don't know why. This is all the code: import java.awt.image

AffineTransform truncates image, what do I wrong?

◇◆丶佛笑我妖孽 提交于 2019-11-28 00:30:59
I have here an black/white png file of the dimensions 2156x1728 which I want to rotate 90 degrees using AffineTransform. The resulting image doesn't have the right proportions. Here some example code (given I have successfully loaded the png file into the BufferedImage ): public BufferedImage transform(BufferedImage image){ System.out.println("Input width: "+ image.getWidth()); System.out.println("Input height: "+ image.getHeight()); AffineTransform affineTransform = new AffineTransform(); affineTransform.setToQuadrantRotation(1, image.getWidth() / 2, image.getHeight() / 2); AffineTransformOp

Graphics Context misaligned on first paint

不羁的心 提交于 2019-11-27 16:00:53
I've been working up an answer for another question and came across a bizare issue that I've not seen before... Basically, the program uses a AffineTransform to provide translation, scaling and rotating of a Graphics element, simple enough stuff, done a thousand times before The problem is, when the screen first appears, the output is not where it should be, but once I touch one of the controls (adjust one of the slides) it jumps to the right spot. Based on the screen shots, the Graphics content seems to be misplaced by the amount of the other controls. If I remove the controls from the GUI,

how to perform coordinates affine transformation using python? part 2

柔情痞子 提交于 2019-11-27 15:00:28
问题 I have same problem as described here: how to perform coordinates affine transformation using python? I was trying to use method described but some reason I will get error messages. Changes I made to code was to replace primary system and secondary system points. I created secondary coordinate points by using different origo. In real case for which I am studying this topic will have some errors when measuring the coordinates. primary_system1 = (40.0, 1160.0, 0.0) primary_system2 = (40.0, 40.0

How to directly rotate CVImageBuffer image in IOS 4 without converting to UIImage?

时光毁灭记忆、已成空白 提交于 2019-11-27 11:43:58
I am using OpenCV 2.2 on the iPhone to detect faces. I'm using the IOS 4's AVCaptureSession to get access to the camera stream, as seen in the code that follows. My challenge is that the video frames come in as CVBufferRef (pointers to CVImageBuffer) objects, and they come in oriented as a landscape, 480px wide by 300px high. This is fine if you are holding the phone sideways, but when the phone is held in the upright position I want to rotate these frames 90 degrees clockwise so that OpenCV can find the faces correctly. I could convert the CVBufferRef to a CGImage, then to a UIImage, and then

Scaling/Translating a Shape to a given Rectangle using AffineTransform

旧城冷巷雨未停 提交于 2019-11-27 09:36:09
I'm trying to scale/translate a java.awt. Shape with AffineTransform in order to draw it in a defined bounding Rectangle. Moreover, I want to paint it in a drawing Area having a ' zoom ' parameter. I tried various concatenations of AffineTransform but I couldn't find the correct sequence. For example, the following solution was wrong: double zoom=(...);/* current zoom */ Rectangle2D viewRect=(...)/** the rectangle where we want to paint the shape */ Shape shape=(...)/* the original shape that should fit in the rectangle viewRect */ Rectangle2D bounds=shape.getBounds2D(); double ratioW=

Drawing transform independent layout bounds in JavaFX

这一生的挚爱 提交于 2019-11-27 07:12:51
问题 For a simple vector drawing app I am looking to implement a "Selection Box", that is a graphic representation of the layoutBounds of a Node. Example: Thanks to jewelsea and his BoundsExample, I have a good understanding now on how to get the data for the box. The part I am struggling with is actually drawing the box on the scene, in a way that correctly respects the transformations on the nodes. Correctly in this case means the bounds logical size get scaled with a node, but the stroke of the

AffineTransform.rotate() - how do I xlate, rotate, and scale at the same time?

早过忘川 提交于 2019-11-27 05:39:23
I have the following code which does (the first part of) what I want drawing a chessboard with some pieces on it. Image pieceImage = getImage(currentPiece); int pieceHeight = pieceImage.getHeight(null); double scale = (double)side/(double)pieceHeight; AffineTransform transform = new AffineTransform(); transform.setToTranslation(xPos, yPos); transform.scale(scale, scale); realGraphics.drawImage(pieceImage, transform, this); that is, it gets a chess piece's image and the image's height, it translates the drawing of that image to the square the piece is on and scales the image to the size of the

AffineTransform truncates image, what do I wrong?

老子叫甜甜 提交于 2019-11-26 23:27:10
问题 I have here an black/white png file of the dimensions 2156x1728 which I want to rotate 90 degrees using AffineTransform. The resulting image doesn't have the right proportions. Here some example code (given I have successfully loaded the png file into the BufferedImage ): public BufferedImage transform(BufferedImage image){ System.out.println("Input width: "+ image.getWidth()); System.out.println("Input height: "+ image.getHeight()); AffineTransform affineTransform = new AffineTransform();