affinetransform

How to implement oval GradientPaint?

不问归期 提交于 2019-12-17 19:53:20
问题 We know that there are a class named RadialGradientPaint in Java and we can use it to have a gradient painting for circle. But I want to have an oval (ellipse) GradientPaint . How to implement oval GradientPaint ? 回答1: Use an AffineTransform when drawing the RadialGradientPaint . This would require a scale instance of the transform. It might end up looking something like this: import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import java.awt.geom.*; import java.awt.event.*

How do I translate parabolically?

岁酱吖の 提交于 2019-12-17 18:10:18
问题 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? 回答1: To animate along a smooth curve, you'll want to

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

旧巷老猫 提交于 2019-12-17 10:29:26
问题 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

Rotate an image in java

北城余情 提交于 2019-12-17 05:11:12
问题 I am looking to rotate an image. I have a JInternalFrame which contains a JLabel . The label contains the image. After the image has been rotated, I need to resize the internal frame. The code I have currently rotates the image, but there is black around the edges of the image and it is off centered. Any suggestions on how to fix this? public void rotateIcon(int angle) { int w = theLabel.getIcon().getIconWidth(); int h = theLabel.getIcon().getIconHeight(); int type = BufferedImage.TYPE_INT

Rotating Image with AffineTransform

只愿长相守 提交于 2019-12-17 02:32:00
问题 I have got class called Airplane . Inside this class i have got variable img which is a BufferedImage type. What is more i have got class WorldMap which overrides function paintComponent(Graphics g) : @Override public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.drawImage(mapa, 0, 0, getWidth(), getHeight(), null); drawAirplanes(g2d); } Function drawAirplanes() look like this: private void drawAirplane(Graphics2D g){ for(Samolot i: s){ i.rotateAirplane(); g.drawImage

Affine transformation matrix offset

[亡魂溺海] 提交于 2019-12-13 12:05:09
问题 This has been killing me the last few days. Not even kidding, but I've been really stressing over this trying to solve it. I am currently trying to use affine transformation matrices to create an isometric projection in HTML5. I receive a tile which is a square that is rotated 45 degrees (essentially a square diamond on a square canvas). I then scale one of the axis' depending on if the there is a delta in the x or y direction. I then skew the axis by a factor to fit. Then, I negate the

How to use warp_matrix (from cv2.findTransformECC) with cv2.transform

夙愿已清 提交于 2019-12-13 03:39:27
问题 I've got an shape defined by an array of points [[x1,y1],[x2,y2],...,[xn,yn]] and an image (img1) with (almost) by I need to find where is this shape, by that I mean if a draw this shape at an arbitrary place on an image (img2) I find the affine transformation to go from an img1 to img2. I managed to do this cv2.findTransformECC. I get a warp_matrix. [img1] https://i.imgur.com/097V8YM.png [img2] https://i.imgur.com/dNUrgE8.png The code : def get_gradient(im) : # Calculate the x and y

Zoom in and out of jPanel

别来无恙 提交于 2019-12-12 18:13:10
问题 I am wondering what is the best way to retrieve the location of a mouse clic after a zoom was made using paintComponent of a panel? (The location relative to this zoom). Here's the zoom code : public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; if(zoomer==true){ at.scale(zoom,zoom);//at = AffineTransform... zoomer=false; } g2.transform(at); In my main class, I use a mouse listener private class and override the mouseRelase method : @Override

How to apply an affine transformation (4x4 matrix) to ndgrid/meshgrid results?

允我心安 提交于 2019-12-12 12:25:43
问题 M is an affine transformation matrix that can transform coordinates from one coordinate system to another as follows: v_old = [ x_old y_old z_old 1]; v_new = M * v_old; % v_new contains [ x_new y_new z_new 1 ] Now, I've got coordinates on the form of ndgrid/meshgrid: [ X_old Y_old Z_old ] = ndgrid( 0:15 ); % for instance How can I convert these to X_new etc? I could do it with three for-loops loop ( X_old(i,j,k) corresponds to x_old above) but there must be a better solution. 回答1: You just

Updating a rotated JLabel using Graphics2D causes old and new text to merge together

馋奶兔 提交于 2019-12-11 18:22:56
问题 I am trying to rotate a JLabel 90 degrees that shows the current time 90 degrees. After doing some research, most people have recommended using Graphics2D and AffineTransform. This almost works, but when the minute in the time is updated, the new digit appears to merge with the old digit. This does not happen for the seconds. Does anybody have any idea how to fix this issue or have an alternate solution? Driver class: import java.awt.Color; import java.awt.Dimension; import java.awt