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

Posts: 35
Registered: ‎05-11-2011
My Device: 9800
My Carrier: bell
Accepted Solution

writing bitmap problem

I have a bitmap to write, this is the code I use:


        // array is my 0-1 indicator matrix
        int[] imgdata = new int[width*height];
        Bitmap bitmap  = new Bitmap(width, height); 
        for (int y = 0; y < height; y++) { 
        	for (int x = 0; x< width; x++){
        		if (array[y][x] == 0)
        				imgdata[y * width + x] = 0x00FFFFFF;
        				imgdata[y * width + x] = 0x00000000;
bitmap.setARGB(imgdata, 0, width, 0, 0, width, height); //if visualize it is white~~~
// resize to large bitmap
		Bitmap retmap = new Bitmap(5*width, 5*height);
		bitmap.scaleInto(retmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT);	
		return retmap;

 But the image turn out to be like this:



I only want the clear matrix but it give me some blurred image. 


Anyone know how to convert a 0-1 matrix to a bitmap and resize it without blur it?

Posts: 202
Registered: ‎04-19-2011
My Device: Blackberry Bold 9780
My Carrier: TAM

Re: writing bitmap problem

sorry, i can't view your image...


and i think tour purpose is to make white become black and black become white, is it?

the blur effect i think, it's because you scaled 5 times bigger and using Filter_bilinear..


try to read in wiki article abou image scaling




Posts: 35
Registered: ‎05-11-2011
My Device: 9800
My Carrier: bell

Re: writing bitmap problem

Hi, man,


you are right, when I use the function to rescale, I did blur it, so I just use a larger bitmap and fill the pixel, it works fine.