BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 09-01-2009, 08:31 AM   #1
abhijeetrajenamdeo
New Member
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Airtel
Posts: 6
Default How to rotate imege in many angles.

Please Login to Remove!

Hi All,

I am trying to rotate image in many angles, just like cd rotation.
Please give me suggestion to do this.

I got some methods like drawTexturedPath-

int displayWidth = Display.getWidth();
int displayHeight = Display.getHeight();
int[] x = new int[] { 0, displayWidth, displayWidth, 0 };
int[] x = new int[] { 0, 0, displayHeight, displayHeight };
int angle = Fixed32.toFP( 45 );
int dux = Fixed32.cosd(angle );
int dvx = -Fixed32.sind( angle );
int duy = Fixed32.sind( angle );
int dvy = Fixed32.cosd( angle );
graphics.drawTexturedPath( x, y, null, null, 0, 0, dvx, dux, dvy, duy, image);




But not able to rotate image in a single point with different angle.

Please reply.

Thanks a lot in advace.
Offline  
Old 01-27-2010, 01:38 AM   #2
pravipravi
Knows Where the Search Button Is
 
Join Date: Jul 2008
Location: India
Model: 9000
Carrier: AirTel
Posts: 29
Default

I used this way for rotating a bitmap image. But it is redusing the image quality on each rotation. Can any one suggest a better way ?

Code:
    public static Bitmap rotateImage(Bitmap oldB, int angle) throws Exception
    {
        int w = oldB.getWidth();
        int h = oldB.getHeight();
        
        double angRad = (angle % 360)*(Math.PI/180);
        Bitmap newB = new Bitmap(w,h);
        
        int[] oldD = new int[w*h];
        int[] newD = new int[w*h];
        
        oldB.getARGB(oldD, 0, w, 0, 0, w, h);
        
        int axisX = w/2;
        int axisY = h/2;
        
        for(int x = 0; x < oldD.length; x++)
        {
            int oldX = x%w;
            int oldY = x/w;
            int op = oldX-axisX;
            int adj = oldY-axisY;
            
            double oldT = MathUtilities.atan2(op, adj);
            double rad = Math.sqrt((op*op)+(adj*adj));
            double newT = oldT+angRad;
            
            int newX = (int)MathUtilities.round((rad*Math.sin(newT))+(double)axisX);
            int newY = (int)MathUtilities.round((rad*Math.cos(newT))+(double)axisY);
            
            if(newX<0||newY<0||newX>=w||newY>=h)
            {
                newD[x] = 0x00000000;
            }
            else
            {
                newD[x] = oldD[(newY*w)+newX];
            }
        }
        
        newB.setARGB(newD, 0, w, 0, 0, w, h);
        return newB;
    }
My problem describes below.

1. I have some bytes of image.
2. I want to rotate image by 90 degree.
3. I want to keep aspect ration , and need image as bytes in back.

Here I used PngEncodedImage api for retrieving Bitmap to byte[] . But its making poor quality image.

Pleas suggest ..!!
__________________
Praveen K
Offline  
Old 02-03-2010, 01:46 AM   #3
pravipravi
Knows Where the Search Button Is
 
Join Date: Jul 2008
Location: India
Model: 9000
Carrier: AirTel
Posts: 29
Default

Anyone there ?

While using the above method , iam geting issue with big images. If we are rotating images with size more than 30 kb size , its adding some black areas around the width.

How can i have a complete image rotator ?
__________________
Praveen K
Offline  
Old 03-06-2010, 10:43 PM   #4
M1ark
New Member
 
Join Date: Mar 2010
Model: sa
PIN: N/A
Carrier: asd
Posts: 1
Default

I would save the images somewhere at an angle just how I wanted, then load them into a quality rotator from there. Look up Complete Image Rotator from Mooonbaby into a search. Like I have one of those Complete Image rotators from there and loading any images and more into those work great.
Offline  
Old 03-25-2010, 01:58 AM   #5
packiaraj
New Member
 
Join Date: Mar 2010
Model: 9530
PIN: N/A
Carrier: test
Posts: 4
Default

Hi to all,
how to use above coding i'm getting MathUtilities error did u use any userdefined function?
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


OEM iPhone 11 PRO X/XR XS MAX 8/7 PLUS Fast Charging USB Cable 10 Feet & 6 Feet  picture

OEM iPhone 11 PRO X/XR XS MAX 8/7 PLUS Fast Charging USB Cable 10 Feet & 6 Feet

$2.99



10 Feet/3M For iPhone 13 12 11 PRO MAX MINI  X XR XS 8 7 Fast Charging USB Cable picture

10 Feet/3M For iPhone 13 12 11 PRO MAX MINI X XR XS 8 7 Fast Charging USB Cable

$5.00



10 Foot/3M iPhone 12/11 PRO MAX X/10 XR XS 8/7 FAST Charging USB LONG Cable cord picture

10 Foot/3M iPhone 12/11 PRO MAX X/10 XR XS 8/7 FAST Charging USB LONG Cable cord

$4.98



iPhone 13 12 11 PRO MAX XR XS 8/7/6 Fast Charger USB Data Cable cord 10 feet/3M picture

iPhone 13 12 11 PRO MAX XR XS 8/7/6 Fast Charger USB Data Cable cord 10 feet/3M

$4.99



Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013 picture

Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013

$37.90



NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch picture

NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch

$31.90







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.