> I can't tell why you are having a problem since the code gives me the
> gradient on the right in your example.
[quoted text clipped - 4 lines]
> then get an interference pattern with bytes being put in inappropriate
> places in the array.
The width is always the same... I think.
I tried walking trough hell since that absolutely new to me by adding a
Direct Color Model and have a 'nicer' gradient.
BUT I cant get the blue only color. If I vary the numbers in the
colormodel I get green, blue and yellow, cyan....
This line does not help too //c = ((0xff) & (byte)(Math.abs (Math.sin((y
+ height) * radianConversion)) * 255));
Jean
=============================================================
/*<applet codebase="." code="BgGradient" width=400 height=200 >
</applet>
*/
import java.awt.*;
import java.awt.image.*;
public class BgGradient extends java.applet.Applet {
Image i;
int width = 400;
int height = 50;
public void init () {
int[] pixels = new int [width * height];
int c;
double radianConversion = (0.45*Math.PI / 180.0);
for (int index = 0, y = 0;y < height;y++) {
c = ((0xff) & (byte)(y* 255/(height - 1)));
for (int x = 0;x < width;x++) {
pixels[index++] = ((0<<24) | 255);//((c << 24) | (c << 16) | (c <<
8) | 255);
}
}
------------------------------------------------------------>
>------
i = createImage (new MemoryImageSource (width, height, new
DirectColorModel((255 << 16) , (255 << 8), 255,(255 << 24) ) ,pixels, 0,
width));
setFont (new Font ("TimesRoman", Font.BOLD | Font.ITALIC, 32));
}
public void paint (Graphics g) {
//setBackground(Color.black);
g.drawImage (i, 0, 3*height, this);
g.drawString ("JeanPierreDaviau.com", 30, 80);
}
}
Andrew Hobbs - 16 Mar 2004 12:35 GMT
I am not sure what you are doing now. However what I am saying is that the
code you originally posted worked well for me, just as in your example.
Have you tried running that exact code. I don't mean running code that you
think is the same, but actually cut and pasted it into a file and run it.
How about cutting and pasting the actual code that is giving you the problem
into your reply. If it really is too big how about cutting it down and
making sure it isn't working and then cutting and pasting.
Cheers
Andrew
--
********************************************************
Andrew Hobbs PhD
MetaSense Pty Ltd - www.metasense.com.au
Australia
61 8 9246 2026
metasens AntiSpam @iinet dot net dot au
*********************************************************
Andrew Thompson - 16 Mar 2004 13:02 GMT
....
> I am not sure what you are doing now. However what I am saying is that the
> code you originally posted worked well for me, just as in your example.
Or, to put that another way..
<http://www.physci.org/test/screenshot/Gradient1.png>
On the basis that, a picture paints a thousand words.. ;-)

Signature
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
Andrew Hobbs - 16 Mar 2004 15:05 GMT
...
> Or, to put that another way..
> <http://www.physci.org/test/screenshot/Gradient1.png>
Quite
Andrew
--
********************************************************
Andrew Hobbs PhD
MetaSense Pty Ltd - www.metasense.com.au
Australia
61 8 9246 2026
metasens AntiSpam @iinet dot net dot au
*********************************************************
Jon A. Cruz - 16 Mar 2004 18:17 GMT
Québec wrote:
> I tried walking trough hell since that absolutely new to me by adding a
> Direct Color Model and have a 'nicer' gradient.
> BUT I cant get the blue only color. If I vary the numbers in the
> colormodel I get green, blue and yellow, cyan....
> This line does not help too //c = ((0xff) & (byte)(Math.abs (Math.sin((y
> + height) * radianConversion)) * 255));
Try breaking it down to more manageable and understandable code.
(Despite any rumors going around out there, shoving stuff to a single
line does not make a program any faster)
int r = 0x0ff & something;
int g = 0x0ff & or;
int b = 0x0ff & another;
c = (r << 16) | (g << 8) | (b << 0);
Once you have it broken down to something like that, it should be easier
to isolate b and what values you're getting for it.