You Are Here:

Community: Developer Discussion Boards

#1 Old Unhappy Gradient Fill Banding Problems - 2005-09-14, 13:31

Join Date: Aug 2003
Posts: 6
benc_1
Offline
Registered User
I've created a method that returns an image containing a gradient fill. I create an RGB array and smoothly change between the 2 colours. I then return the image created using Image.createRGBImage.

When i run the app on the device (6630) quite a lot of banding between the colours is visible.

I tried exactly the same gradient fill on an image and there was no banding so i know its possible to have a smooth transition.

I have tried taking the RGB data and creating a PNG manually (using CRC and Adler checksums etc) then loading that in as a byte[] which also works fine (but is more expensive and complex than the createRGBImage).

I have tried taking an image with the gradient fill on, getting the RGB data from it and then recreating the image again with createRGBImage and that works fine.

The device must therefore convert the RGB values when reading in a PNG into a screen friendly format but i've no idea how it does this. Can anybody shed some light on this for me?

And yes I know the device format is 5:6:5 RGB but looking at the values from getRGB it hasn't converted them into that.
Reply With Quote

#2 Old Re: Gradient Fill Banding Problems - 2005-09-14, 14:10

Join Date: Jan 2004
Posts: 82
Leicester22
Offline
Regular Contributor
Quote:
Originally Posted by benc_1
The device must therefore convert the RGB values when reading in a PNG into a screen friendly format but i've no idea how it does this. Can anybody shed some light on this for me?
Everytime you open a image with Image.createImage(..) The image is decoded and stored in a "screen friendly" format (as some kind of bitmap).


Quote:
Originally Posted by benc_1
And yes I know the device format is 5:6:5 RGB but looking at the values from getRGB it hasn't converted them into that.
The getRGB() method returns an integer array with one integer = one pixel, see javadoc of getRGB() for the next (and even more):
Quote:
Obtains ARGB pixel data from the specified region of this image and stores it in the provided array of integers. Each pixel value is stored in 0xAARRGGBB format, where the high-order byte contains the alpha channel and the remaining bytes contain color components for red, green and blue, respectively.
The returned values are not guaranteed to be identical to values from the original source, such as from createRGBImage or from a PNG image. Color values may be resampled to reflect the display capabilities of the device...
I've written a method a while ago that creates an "gradient-array" You could try it...
It returns an array that starts with aStartColor and turns smoothly into aEndcolor. aLength determines the length of the array(gradient).
Code:
public int[] getGradient(int aStartColor, int aEndColor, int aLength){
		
		int r1 = aStartColor>>16;		
		int g1 = aStartColor>>8;
		g1 = g1 & 0x0000FF;
		int b1 = aStartColor;
		b1 = b1 & 0x0000FF;
		
		
		int r2 = aEndColor>>16;		
		int g2 = aEndColor>>8;
		g2 = g2 & 0x0000FF;
		int b2 = aEndColor;
		b2 = b2 & 0x0000FF;
		
		int res_r = 0;
		int res_g = 0;
		int res_b = 0;
		
		int gradient[] = new int[aLength];
		
		int counter = 0;
		int dif;
		while(counter < aLength){
			dif = (aLength-counter);
			res_r =  (r1 * dif + r2*counter)/aLength ;
			res_g =  (g1 * dif + g2*counter)/aLength ;
			res_b =  (b1 * dif + b2*counter)/aLength ;	
			
			res_r = res_r <<16;
			res_g = res_g <<8;
			
			gradient[counter] = (res_r | res_g | res_b);
			         
			counter++;
		}		
		return gradient;
	}
Reply With Quote

#3 Old Re: Gradient Fill Banding Problems - 2005-09-14, 14:53

Join Date: Aug 2003
Posts: 6
benc_1
Offline
Registered User
Thanks for your help, i hadn't seen the text in the getRGB definition.

Tried your gradient code, unfortunately banding still occurs, thanks for the suggestion though.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Usability problems still need fixing. Can we help nokia? Trial General Discussion 3 2004-02-26 16:05
Problems with Nokia carkit CK-1W Batunas General Discussion 1 2004-02-09 19:18
Problems installing Nokia developers suite with JBuilder 8 Personal maaberge Mobile Java Tools & SDKs 0 2003-04-05 01:42
Doing a gradient fill nkn_aikon Symbian User Interface 1 2001-11-28 22:23
Doing a gradient fill nkn_aikon General Symbian C++ 1 2001-11-08 19:48

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ