image gets pixelated when rotated

i have an image with size 1162 x 16 , i want to rotate when the touch event “move” is launched ,
the problem is that when it is rotated it gets pixelated , although it’s not being scaled !!
does anyone have an idea how to fix that ??? [import]uid: 86096 topic_id: 16850 reply_id: 316850[/import]

Use this code. I hope this will help.

rotateObj=function(event)
local t = event.target
local phase = event.phase

if (phase == “began”) then
display.getCurrentStage():setFocus( t )
t.isFocus = true

– Store initial position of finger
t.x1 = event.x
t.y1 = event.y

elseif t.isFocus then
if (phase == “moved”) then
t.x2 = event.x
t.y2 = event.y

angle1 = 180/math.pi * math.atan2(t.y1 - t.y , t.x1 - t.x)
angle2 = 180/math.pi * math.atan2(t.y2 - t.y , t.x2 - t.x)
–print("angle1 = "…angle1)
rotationAmt = angle1 - angle2

–rotate it
t.rotation = t.rotation - rotationAmt
–print ("t.rotation = "…t.rotation)

t.x1 = t.x2
t.y1 = t.y2

elseif (phase == “ended”) then

display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end

– Stop further propagation of touch event
return true
end [import]uid: 75428 topic_id: 16850 reply_id: 63091[/import]

thx sabir.ahmed59 i tried it , still i have the same problem , it does not seem that the problem is with the rotation code, i think it is related to the image size :S [import]uid: 86096 topic_id: 16850 reply_id: 63093[/import]

Can you send me your code for more detail? [import]uid: 75428 topic_id: 16850 reply_id: 63100[/import]

here is my code :

[code]
local bck = display.newRect (0,0,display.contentWidth,display.contentHeight)
bck.x = display.contentWidth * 0.5
bck.y = display.contentHeight * 0.5
bck:setFillColor (255,255,255)

local img = display.newImageRect (“laser1.png”,1170,1170)
img.x = display.contentWidth * 0.5
img.y = display.contentHeight * 0.5
local function getRotation(PointX1,PointY1,PointX2,PointY2)
–display.getCurrentStage():setFocus ( Bug )
local atan2 = math.atan2
local pi = 3.14159265358

local deltax = PointX2 - PointX1
local deltay = PointY2 - PointY1

local currentAngle = ((atan2(deltay,deltax) )* 180.0) / pi
local rotationDigree = currentAngle - img.previousAngle;

img.previousAngle = currentAngle

return rotationDigree;
end

local function handleTouch ( event )
img.previousAngle = 1
if( event.phase == “moved” ) then
img.rotation = getRotation ( img.x , img.y , event.x , event.y )
end
end
Runtime:addEventListener (“touch”,handleTouch)
[/code] [import]uid: 86096 topic_id: 16850 reply_id: 63101[/import]

Hi,
I used your code and not found any issued.
I don’t know why you having problem. [import]uid: 75428 topic_id: 16850 reply_id: 63102[/import]

it’s not an issue in the code , the image gets pixelated when rotated , i want to handle this problem , i don’t want the image to get pixelated [import]uid: 86096 topic_id: 16850 reply_id: 63103[/import]

what is the resolution of your image and what is the image?
There will be slight pixellation on rotation, now it all depends on what you consider as pixellation and whatt you don’t.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16850 reply_id: 63112[/import]

@israa.khalifeh, do your images have transparent padding? I always give my images transparent padding, 5 pixels or more all around. When my images get rotated, if they don’t have the transparent paddings, they sometimes show jagged edges. I do not know if this would help with your situation, but it may be worth a try.

Naomi
[import]uid: 67217 topic_id: 16850 reply_id: 63131[/import]

@JayantV the resolution is 254 pixel/inch , but the pixelation is annoying :S [import]uid: 86096 topic_id: 16850 reply_id: 64217[/import]

@Naomi i already give them about 10px transparent padding , still it is pixelated when rotated [import]uid: 86096 topic_id: 16850 reply_id: 64218[/import]

can you either post the image or screenshot of the pixellation, because it is difficult to determine the issue based on verbal descriptions.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16850 reply_id: 64227[/import]

@israa.khalifeh

Why do you use 254 pixel/inch?

Check out this link for more info about device ppi reference.
The answer to your problem is here. [import]uid: 13560 topic_id: 16850 reply_id: 64265[/import]