The getRGB() method

It's not absolutely necessary to do the bit manipulation yourself. You can instead construct a new java.awt.Color object and use its getRGB() method to return the int value. For example,

  Color purple = new Color(217, 10, 186)
  int p = purple.getRGB();
  int[] pixels = new int[5000];
  for (int i=0; i < pixels.length; i++) pixels[i] = p;
  MemoryImageSource purpleMIS = new MemoryImageSource(100, 50, pixels, 0, 50);
  theImage = createImage(purpleMIS);

Previous | Next | Top | Cafe au Lait

Copyright 1997-1999 Elliotte Rusty Harold
Last Modified July 1, 1999