Java Media: Find Components : Media « 2D Graphics GUI « Java






Java Media: Find Components

Java Media: Find Components
/*

Java Media APIs: Cross-Platform Imaging, Media and Visualization
Alejandro Terrazas
Sams, Published November 2002, 
ISBN 0672320940
*/

import java.awt.image.DirectColorModel;

public class FindComponents {
  DirectColorModel dcm32;

  DirectColorModel dcm16;

  int[] components;

  float[] componentsf;

  int value32;

  short value16;

  int red8, green8, blue8, alpha8;

  short red5, green5, blue5;

  /**
   * FindComponents.java -- prints out normalized color components for two
   * different
   */
  public FindComponents() {
    red8 = red5 = 30;
    green8 = green5 = 20;
    blue8 = blue5 = 10;
    alpha8 = 255;

    dcm32 = new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff,
        0xff000000);
    value32 = (alpha8 << 24) + (red8 << 16) + (green8 << 8) + blue8;
    components = dcm32.getComponents(value32, null, 0);
    componentsf = dcm32.getNormalizedComponents(components, 0, null, 0);
    System.out.println("Normalized components are: ");
    for (int i = 0; i < componentsf.length; i++)
      System.out.println("\t" + componentsf[i]);

    dcm16 = new DirectColorModel(16, 0x7c00, 0x3e0, 0x1f);
    value16 = (short) ((red5 << 10) + (green5 << 5) + blue5);
    components = dcm16.getComponents(value16, null, 0);
    componentsf = dcm16.getNormalizedComponents(components, 0, null, 0);
    System.out.println("Normalized components are: ");
    for (int i = 0; i < componentsf.length; i++)
      System.out.println("\t" + componentsf[i]);
  }

  public static void main(String[] args) {
    new FindComponents();
  }
}

           
       








Related examples in the same category

1.Query the manager class about the configuration and support of JMFQuery the manager class about the configuration and support of JMF
2.Show the Location2Location class in actionShow the Location2Location class in action
3.Capture audio or video through devices connected to the PC
4.Choose the media they wish to playChoose the media they wish to play
5.Do Audio Capture
6.Statistics about the tracks that compose a media object
7.Play the media object
8.A Bare Bones Player: play the media object
9.Play the media object 3
10.List all capture devices currently known to the JMFList all capture devices currently known to the JMF
11.Transfer media from one location to another carrying out the specified