image-rotation

rotating an image 90 degrees in java [duplicate]

纵然是瞬间 提交于 2019-11-27 14:02:07
问题 This question already has an answer here: Java: Rotating Images 4 answers I have managed to rotate an image 180 degrees but wish to rotate it 90 degrees clockwise can someone edit my code so that it does this with explanation. Thanks. private void rotateClockwise() { if(currentImage != null){ int width = currentImage.getWidth(); int height = currentImage.getHeight(); OFImage newImage = new OFImage(width, height); for(int y = 0; y < height; y++) { for(int x = 0; x < width; x++) { newImage

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

Rotate JLabel or ImageIcon on Java Swing

懵懂的女人 提交于 2019-11-27 05:28:37
first of all, this is the first week that I use swing, then sorry if my question is too obvious. Also, I need solutions that use the standard java libraries, since this is for homework and I'm not allowed to use strange libraries. I'm using JLabel with ImageIcon to show images on a JFrame. Now I want to rotate the image on screen to arbitrary angles. I found something about Graphics2D but i don't find the way to do that. Since solutions that I found doesn't work or I don't understand them, I'm interested in any solution to rotate the ImageIcon or the JLabel. Since I'm positioning the image

How To Rotate Image By Nearest Neighbor Interpolation Using Matlab

…衆ロ難τιáo~ 提交于 2019-11-27 02:50:32
问题 My Plain Code without interpolation: im1 = imread('lena.jpg');imshow(im1); [m,n,p]=size(im1); thet = rand(1); m1=m*cos(thet)+n*sin(thet); n1=m*sin(thet)+n*cos(thet); for i=1:m for j=1:n t = uint16((i-m/2)*cos(thet)-(j-n/2)*sin(thet)+m1/2); s = uint16((i-m/2)*sin(thet)+(j-n/2)*cos(thet)+n1/2); if t~=0 && s~=0 im2(t,s,:)=im1(i,j,:); end end end figure; imshow(im2); This code creates black spot, the problem is how to do interpolation? Thank you all for any illumination. P.S. Not asking for build

Java 2d rotation in direction mouse point

ⅰ亾dé卋堺 提交于 2019-11-27 01:56:40
So far I have a java app where I draw a circle(player) and then draw a green rectangle on top(gun barrel). I have it so when the player moves, the barrel follows with it. I want it to find where the mouse is pointing and then rotate the barrel accordingly. For an example of what I mean look at this video I found http://www.youtube.com/watch?v=8W7WSkQq5SU See how the player image reacts when he moves the mouse around? Here's an image of what the game looks like so far: So how do I rotate it like this? Btw I don't like using affinetransform or Graphics2D rotation. I was hoping for a better way.

How to rotate image and save the image

时间秒杀一切 提交于 2019-11-26 16:17:24
问题 In my application i have an image in a div,a button. I want to rotate the image displayed and save the rotated image when i clicked on the button using jquery. I already used the code: http://code.google.com/p/jquery-rotate/ and jquery code: $(function() { // doc ready var rotation = 0; // variable to do rotation with $("#img").click(function() { rotation = (rotation + 45) % 360; // the mod 360 probably isn't needed $("#cropbox").rotate(rotation); }); }); html code: <img src="demo_files/pool

How to programmatically rotate image by 90 Degrees in iPhone? [duplicate]

孤者浪人 提交于 2019-11-26 15:48:25
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How to Rotate a UIImage 90 degrees? How to programmatically rotate image by 90 Degrees in iPhone? 回答1: //create rect UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_image.png"]]; //set point of rotation myImageView.center = CGPointMake(100.0, 100.0); //rotate rect myImageView.transform = CGAffineTransformMakeRotation(M_PI_2); //rotation in radians 回答2: see this: Rotate

How To Create a Rotating Wheel Control?

孤者浪人 提交于 2019-11-26 15:47:30
问题 I am trying to implement the Rotatory wheel in android, just like the image displayed below.I came across the tutorial from this link. But i want to implement just as shown in the below image.The wheel consists of individual images.Does anybody have any idea regarding this implementation?? Any help would be appreciated. Thanks in advance. Akash 回答1: To do this from scratch, you would need a way to transform your touch coordinates, into polar coordinates (to have the rotation angle). This can

Android: How to rotate a bitmap on a center point

只谈情不闲聊 提交于 2019-11-26 14:57:34
I've been looking for over a day for a solution to this problem but nothing helps, even the answers here. Documentation doesn't explain anything too. I am simply trying to get a rotation in the direction of another object. The problem is that the bitmap is not rotated around a fixed point, but rather around the bitmaps (0,0). Here is the code I am having troubles with: Matrix mtx = new Matrix(); mtx.reset(); mtx.preTranslate(-centerX, -centerY); mtx.setRotate((float)direction, -centerX, -centerY); mtx.postTranslate(pivotX, pivotY); Bitmap rotatedBMP = Bitmap.createBitmap(bitmap, 0, 0,

Rotate JLabel or ImageIcon on Java Swing

删除回忆录丶 提交于 2019-11-26 12:47:24
问题 first of all, this is the first week that I use swing, then sorry if my question is too obvious. Also, I need solutions that use the standard java libraries, since this is for homework and I\'m not allowed to use strange libraries. I\'m using JLabel with ImageIcon to show images on a JFrame. Now I want to rotate the image on screen to arbitrary angles. I found something about Graphics2D but i don\'t find the way to do that. Since solutions that I found doesn\'t work or I don\'t understand