Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 41
Registered: ‎04-24-2012
My Device: storm
My Carrier: blackberry

Graphics contents to bitmap

Hi Im just gonna ask if it is possible to transfer the contents of a Graphics class to a bitmap. But currently im trying to rotate may drawings from the graphics class but most of the examples rotate bitmaps. Is this possible tnx in advance.

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Graphics contents to bitmap

you can use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/Graphics.html#create(net.ri... to link graphics with a bitmap
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 41
Registered: ‎04-24-2012
My Device: storm
My Carrier: blackberry

Re: Graphics contents to bitmap

is it possible the opposite of that? Example I draw sevaral Rectangles using drawRect method is it possible to convert this recatangles in Bitmap? What I'm trying to do is to rotate my drawings example a Rectangle, Gradient RoundedRectangle etc.

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Graphics contents to bitmap

and what is wrong with drawing them on the graphics object you created using the method above?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 41
Registered: ‎04-24-2012
My Device: storm
My Carrier: blackberry

Re: Graphics contents to bitmap

because want i'm trying to do is I would like to draw example a shape and turn it into a bitmap. When I tried to use Graphics.create it makes a rectangle area to draw which is what I need. But the problem is that the area is a rectangle I would like to make the area of the bitmap to exactly what I draw example a circle. Below is the test class that I used.
 protected void paint(Graphics g)
    {
    int _width = Display.getWidth();
    int _height = Display.getHeight();
    graphics.setColor(Color.RED);
    graphics.fillRect(0, 0, 480, 800);
    Bitmap result = new Bitmap(_width, _height);
        Graphics grap = Graphics.create(result);
        grap.setColor(0xCCCCCC);
        grap.fillEllipse(100, 200, 160, 240, 100, 270, 0, 360);
        grap.drawEllipse(105, 205, 165, 245, 105, 275, 0, 360);
    g.drawBitmap(50, 50, 200, 200, surface, 0, 0);
    }

Highlighted
Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Graphics contents to bitmap

as far as i know a bitmap represents an area defined by with and height (a rectangle), not a circle or another shape.
you can use transparency to have parts of it transparent, but that's as far as it goes.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter