API java : PackedColorModel


java.awt.image
Class PackedColorModel

java.lang.Object
  extended by java.awt.image.ColorModel
      extended by java.awt.image.PackedColorModel
All Implemented Interfaces:
Transparency
Direct Known Subclasses:
DirectColorModel

public abstract class PackedColorModel
extends ColorModel

The PackedColorModel class is an abstract ColorModel class that works with pixel values which represent color and alpha information as separate samples and which pack all samples for a single pixel into a single int, short, or byte quantity. This class can be used with an arbitrary ColorSpace. The number of color samples in the pixel values must be the same as the number of color components in the ColorSpace. There can be a single alpha sample. The array length is always 1 for those methods that use a primitive array pixel representation of type transferType. The transfer types supported are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT. Color and alpha samples are stored in the single element of the array in bits indicated by bit masks. Each bit mask must be contiguous and masks must not overlap. The same masks apply to the single int pixel representation used by other methods. The correspondence of masks and color/alpha samples is as follows:

  • Masks are identified by indices running from 0 through getNumComponents - 1.
  • The first getNumColorComponents indices refer to color samples.
  • If an alpha sample is present, it corresponds the last index.
  • The order of the color indices is specified by the ColorSpace. Typically, this reflects the name of the color space type (for example, TYPE_RGB), index 0 corresponds to red, index 1 to green, and index 2 to blue.

The translation from pixel values to color/alpha components for display or processing purposes is a one-to-one correspondence of samples to components. A PackedColorModel is typically used with image data that uses masks to define packed samples. For example, a PackedColorModel can be used in conjunction with a SinglePixelPackedSampleModel to construct a BufferedImage. Normally the masks used by the SampleModel and the ColorModel would be the same. However, if they are different, the color interpretation of pixel data is done according to the masks of the ColorModel.

A single int pixel representation is valid for all objects of this class since it is always possible to represent pixel values used with this class in a single int. Therefore, methods that use this representation do not throw an IllegalArgumentException due to an invalid pixel value.

A subclass of PackedColorModel is DirectColorModel, which is similar to an X11 TrueColor visual.

See Also:
DirectColorModel, SinglePixelPackedSampleModel, BufferedImage

Field Summary
 
Fields inherited from class java.awt.image.ColorModel
pixel_bits, transferType
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
PackedColorModel(ColorSpace space, int bits, int[] colorMaskArray, int alphaMask, boolean isAlphaPremultiplied, int trans, int transferType)
          Constructs a PackedColorModel from a color mask array, which specifies which bits in an int pixel representation contain each of the color samples, and an alpha mask.
PackedColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int trans, int transferType)
          Constructs a PackedColorModel from the specified masks which indicate which bits in an int pixel representation contain the alpha, red, green and blue color samples.
 
Method Summary
 SampleModel createCompatibleSampleModel(int w, int h)
          Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel.
 boolean equals(Object obj)
          Tests if the specified Object is an instance of PackedColorModel and equals this PackedColorModel.
 WritableRaster getAlphaRaster(WritableRaster raster)
          Returns a WritableRaster representing the alpha channel of an image, extracted from the input WritableRaster.
 int getMask(int index)
          Returns the mask indicating which bits in a pixel contain the specified color/alpha sample.
 int[] getMasks()
          Returns a mask array indicating which bits in a pixel contain the color and alpha samples.
 boolean isCompatibleSampleModel(SampleModel sm)
          Checks if the specified SampleModel is compatible with this ColorModel.
 
Methods inherited from class java.awt.image.ColorModel
coerceData, createCompatibleWritableRaster, finalize, getAlpha, getAlpha, getBlue, getBlue, getColorSpace, getComponents, getComponents, getComponentSize, getComponentSize, getDataElement, getDataElement, getDataElements, getDataElements, getDataElements, getGreen, getGreen, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRed, getRed, getRGB, getRGB, getRGBdefault, getTransferType, getTransparency, getUnnormalizedComponents, hasAlpha, hashCode, isAlphaPremultiplied, isCompatibleRaster, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PackedColorModel

public PackedColorModel(ColorSpace space,
                        int bits,
                        int[] colorMaskArray,
                        int alphaMask,
                        boolean isAlphaPremultiplied,
                        int trans,
                        int transferType)
Constructs a PackedColorModel from a color mask array, which specifies which bits in an int pixel representation contain each of the color samples, and an alpha mask. Color components are in the specified ColorSpace. The length of colorMaskArray should be the number of components in the ColorSpace. All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of an int pixel representation. If the alphaMask is 0, there is no alpha. If there is alpha, the boolean isAlphaPremultiplied specifies how to interpret color and alpha samples in pixel values. If the boolean is true, color samples are assumed to have been multiplied by the alpha sample. The transparency, trans, specifies what alpha values can be represented by this color model. The transfer type is the type of primitive array used to represent pixel values.

Parameters:
space - the specified ColorSpace
bits - the number of bits in the pixel values
colorMaskArray - array that specifies the masks representing the bits of the pixel values that represent the color components
alphaMask - specifies the mask representing the bits of the pixel values that represent the alpha component
isAlphaPremultiplied - true if color samples are premultiplied by the alpha sample; false otherwise
trans - specifies the alpha value that can be represented by this color model
transferType - the type of array used to represent pixel values
Throws:
IllegalArgumentException - if bits is less than 1 or greater than 32

PackedColorModel

public PackedColorModel(ColorSpace space,
                        int bits,
                        int rmask,
                        int gmask,
                        int bmask,
                        int amask,
                        boolean isAlphaPremultiplied,
                        int trans,
                        int transferType)
Constructs a PackedColorModel from the specified masks which indicate which bits in an int pixel representation contain the alpha, red, green and blue color samples. Color components are in the specified ColorSpace, which must be of type ColorSpace.TYPE_RGB. All of the bits in each mask must be contiguous and fit in the specified number of least significant bits of an int pixel representation. If amask is 0, there is no alpha. If there is alpha, the boolean isAlphaPremultiplied specifies how to interpret color and alpha samples in pixel values. If the boolean is true, color samples are assumed to have been multiplied by the alpha sample. The transparency, trans, specifies what alpha values can be represented by this color model. The transfer type is the type of primitive array used to represent pixel values.

Parameters:
space - the specified ColorSpace
bits - the number of bits in the pixel values
rmask - specifies the mask representing the bits of the pixel values that represent the red color component
gmask - specifies the mask representing the bits of the pixel values that represent the green color component
bmask - specifies the mask representing the bits of the pixel values that represent the blue color component
amask - specifies the mask representing the bits of the pixel values that represent the alpha component
isAlphaPremultiplied - true if color samples are premultiplied by the alpha sample; false otherwise
trans - specifies the alpha value that can be represented by this color model
transferType - the type of array used to represent pixel values
Throws:
IllegalArgumentException - if space is not a TYPE_RGB space
See Also:
ColorSpace
Method Detail

getMask

public final int getMask(int index)
Returns the mask indicating which bits in a pixel contain the specified color/alpha sample. For color samples, index corresponds to the placement of color sample names in the color space. Thus, an index equal to 0 for a CMYK ColorSpace would correspond to Cyan and an index equal to 1 would correspond to Magenta. If there is alpha, the alpha index would be:
  1. alphaIndex = numComponents() - 1;

Parameters:
index - the specified color or alpha sample
Returns:
the mask, which indicates which bits of the int pixel representation contain the color or alpha sample specified by index.
Throws:
ArrayIndexOutOfBoundsException - if index is greater than the number of components minus 1 in this PackedColorModel or if index is less than zero

getMasks

public final int[] getMasks()
Returns a mask array indicating which bits in a pixel contain the color and alpha samples.

Returns:
the mask array , which indicates which bits of the int pixel representation contain the color or alpha samples.

createCompatibleSampleModel

public SampleModel createCompatibleSampleModel(int w,
                                               int h)
Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel.

Overrides:
createCompatibleSampleModel in class ColorModel
Parameters:
w - the width (in pixels) of the region of the image data described
h - the height (in pixels) of the region of the image data described
Returns:
the newly created SampleModel.
Throws:
IllegalArgumentException - if w or h is not greater than 0
See Also:
SampleModel

isCompatibleSampleModel

public boolean isCompatibleSampleModel(SampleModel sm)
Checks if the specified SampleModel is compatible with this ColorModel. If sm is null, this method returns false.

Overrides:
isCompatibleSampleModel in class ColorModel
Parameters:
sm - the specified SampleModel, or null
Returns:
true if the specified SampleModel is compatible with this ColorModel; false otherwise.
See Also:
SampleModel

getAlphaRaster

public WritableRaster getAlphaRaster(WritableRaster raster)
Returns a WritableRaster representing the alpha channel of an image, extracted from the input WritableRaster. This method assumes that WritableRaster objects associated with this ColorModel store the alpha band, if present, as the last band of image data. Returns null if there is no separate spatial alpha channel associated with this ColorModel. This method creates a new WritableRaster, but shares the data array.

Overrides:
getAlphaRaster in class ColorModel
Parameters:
raster - a WritableRaster containing an image
Returns:
a WritableRaster that represents the alpha channel of the image contained in raster.

equals

public boolean equals(Object obj)
Tests if the specified Object is an instance of PackedColorModel and equals this PackedColorModel.

Overrides:
equals in class ColorModel
Parameters:
obj - the Object to test for equality
Returns:
true if the specified Object is an instance of PackedColorModel and equals this PackedColorModel; false otherwise.
See Also:
Object.hashCode(), Hashtable

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-2082
Document créé le 31/08/06 03:32, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/awt/image/PackedColorModel.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,87 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Si vous avez un peu de patience, vous découvrirez qu'on peut utiliser les immenses ressources du Web pour perdre son temps avec une efficacité que vous n'aviez jamais osé imaginer.

Dave Barry
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 14:55, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)