05-15-2012 05:38 AM - edited 05-15-2012 07:18 AM
Hi All,
I've read the article: http://supportforums.blackberry.com/t5/Java-Develo
I've also search this forum and googled a lot but I can't seem to find the answer to the following:
I have a bitmap image that has a transparent background. When I rotate the image, using ImageManipulator, the transparent background from the original image is changed to white.
The code I use is very simple:
Bitmap bmp = ImageManipulator.rotate(ADIAL_IMAGE, angle); g.drawBitmap(_x, _y, bmp.getWidth(), bmp.getHeight(), bmp, 0, 0);
Is there a way to rotate the image and keep the orginal transparent background?
05-31-2012 10:02 AM
Hi,
Did you find a solution to this issue, am facing the same problem.
BR
Suppi
05-31-2012 10:24 AM
05-31-2012 10:55 AM
Well i think it is possible if the color is updated in paintTransformedBitmap in ImageManipulator class. It is set to White. That is why we get a white background. If we set this to transparent it should work. Question is how to set it to transparent?? is there is a hex code for Transparent??
05-31-2012 11:45 AM
Hi Supriya,
I can suggest you one thing,
You can find the solution for resizing transparent images here:
http://www.patchou.com/2010/10/resizing-transparen
Now what my suggestion is you can club this code (that helps to gaining transparency) with rotate image code.
Give it a try, may be you can do that.
Thanks.
05-31-2012 07:58 PM
Hex code for transparent is 0x00xxxxxx. For completely opaque ii is 0xFFxxxxxx;
06-01-2012 03:42 AM
Hi,
Thanks alot for this.
But if i add 0x00xxxxxx to my code its gives a syntax error, is there something else i shld add or another way of handling it.
06-01-2012 03:45 AM
06-01-2012 03:54 AM
Ah i am so stupid...should have realized that.
Anyways, but then if i add rgb values then i will get an image with some background color. I want a completely transparent color.
I used the below code, but its slow, is there a faster process:
private void drawRotatedBitmap(Graphics graphics, Bitmap bm, int angle, int x, int y) {
int w = bm.getWidth(); int h = bm.getHeight();
double a = Math.toRadians(angle);
int x1 = (int) (x - h * Math.sin(a));
int y1 = (int) (y + h * Math.cos(a));
int x2 = (int) (x1 + w * Math.cos(a));
int y2 = (int) (y1 + w * Math.sin(a));
int x3 = (int) (x + w * Math.cos(a));
int y3 = (int) (y + w * Math.sin(a));
int xPts[] = {x, x1, x2, x3};
int yPts[] = {y, y1, y2, y3};
int fAngle = Fixed32.toFP(angle);
int dvx = Fixed32.cosd(fAngle);
int dux = -Fixed32.sind(fAngle);
int dvy = Fixed32.sind(fAngle);
int duy = Fixed32.cosd(fAngle);
graphics.setDrawingStyle(Graphics.DRAWSTYLE_AAPOLY
graphics.drawTexturedPath(xPts, yPts, null, null, x, y, dvx, dux, dvy, duy, bm);
}