API java : ColorConvertOp


java.awt.image
Class ColorConvertOp

java.lang.Object
  extended by java.awt.image.ColorConvertOp
All Implemented Interfaces:
BufferedImageOp, RasterOp

public class ColorConvertOp
extends Object
implements BufferedImageOp, RasterOp

This class performs a pixel-by-pixel color conversion of the data in the source image. The resulting color values are scaled to the precision of the destination image. Color conversion can be specified via an array of ColorSpace objects or an array of ICC_Profile objects.

If the source is a BufferedImage with premultiplied alpha, the color components are divided by the alpha component before color conversion. If the destination is a BufferedImage with premultiplied alpha, the color components are multiplied by the alpha component after conversion. Rasters are treated as having no alpha channel, i.e. all bands are color bands.

If a RenderingHints object is specified in the constructor, the color rendering hint and the dithering hint may be used to control color conversion.

Note that Source and Destination may be the same object.

See Also:
RenderingHints.KEY_COLOR_RENDERING, RenderingHints.KEY_DITHERING

Constructor Summary
ColorConvertOp(ColorSpace srcCspace, ColorSpace dstCspace, RenderingHints hints)
          Constructs a new ColorConvertOp from two ColorSpace objects.
ColorConvertOp(ColorSpace cspace, RenderingHints hints)
          Constructs a new ColorConvertOp from a ColorSpace object.
ColorConvertOp(ICC_Profile[] profiles, RenderingHints hints)
          Constructs a new ColorConvertOp from an array of ICC_Profiles.
ColorConvertOp(RenderingHints hints)
          Constructs a new ColorConvertOp which will convert from a source color space to a destination color space.
 
Method Summary
 BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM)
          Creates a zeroed destination image with the correct size and number of bands, given this source.
 WritableRaster createCompatibleDestRaster(Raster src)
          Creates a zeroed destination Raster with the correct size and number of bands, given this source.
 BufferedImage filter(BufferedImage src, BufferedImage dest)
          ColorConverts the source BufferedImage.
 WritableRaster filter(Raster src, WritableRaster dest)
          ColorConverts the image data in the source Raster.
 Rectangle2D getBounds2D(BufferedImage src)
          Returns the bounding box of the destination, given this source.
 Rectangle2D getBounds2D(Raster src)
          Returns the bounding box of the destination, given this source.
 ICC_Profile[] getICC_Profiles()
          Returns the array of ICC_Profiles used to construct this ColorConvertOp.
 Point2D getPoint2D(Point2D srcPt, Point2D dstPt)
          Returns the location of the destination point given a point in the source.
 RenderingHints getRenderingHints()
          Returns the rendering hints used by this op.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorConvertOp

public ColorConvertOp(RenderingHints hints)
Constructs a new ColorConvertOp which will convert from a source color space to a destination color space. The RenderingHints argument may be null. This Op can be used only with BufferedImages, and will convert directly from the ColorSpace of the source image to that of the destination. The destination argument of the filter method cannot be specified as null.

Parameters:
hints - the RenderingHints object used to control the color conversion, or null

ColorConvertOp

public ColorConvertOp(ColorSpace cspace,
                      RenderingHints hints)
Constructs a new ColorConvertOp from a ColorSpace object. The RenderingHints argument may be null. This Op can be used only with BufferedImages, and is primarily useful when the filter method is invoked with a destination argument of null. In that case, the ColorSpace defines the destination color space for the destination created by the filter method. Otherwise, the ColorSpace defines an intermediate space to which the source is converted before being converted to the destination space.

Parameters:
cspace - defines the destination ColorSpace or an intermediate ColorSpace
hints - the RenderingHints object used to control the color conversion, or null
Throws:
NullPointerException - if cspace is null

ColorConvertOp

public ColorConvertOp(ColorSpace srcCspace,
                      ColorSpace dstCspace,
                      RenderingHints hints)
Constructs a new ColorConvertOp from two ColorSpace objects. The RenderingHints argument may be null. This Op is primarily useful for calling the filter method on Rasters, in which case the two ColorSpaces define the operation to be performed on the Rasters. In that case, the number of bands in the source Raster must match the number of components in srcCspace, and the number of bands in the destination Raster must match the number of components in dstCspace. For BufferedImages, the two ColorSpaces define intermediate spaces through which the source is converted before being converted to the destination space.

Parameters:
srcCspace - the source ColorSpace
dstCspace - the destination ColorSpace
hints - the RenderingHints object used to control the color conversion, or null
Throws:
NullPointerException - if either srcCspace or dstCspace is null

ColorConvertOp

public ColorConvertOp(ICC_Profile[] profiles,
                      RenderingHints hints)
Constructs a new ColorConvertOp from an array of ICC_Profiles. The RenderingHints argument may be null. The sequence of profiles may include profiles that represent color spaces, profiles that represent effects, etc. If the whole sequence does not represent a well-defined color conversion, an exception is thrown.

For BufferedImages, if the ColorSpace of the source BufferedImage does not match the requirements of the first profile in the array, the first conversion is to an appropriate ColorSpace. If the requirements of the last profile in the array are not met by the ColorSpace of the destination BufferedImage, the last conversion is to the destination's ColorSpace.

For Rasters, the number of bands in the source Raster must match the requirements of the first profile in the array, and the number of bands in the destination Raster must match the requirements of the last profile in the array. The array must have at least two elements or calling the filter method for Rasters will throw an IllegalArgumentException.

Parameters:
profiles - the array of ICC_Profile objects
hints - the RenderingHints object used to control the color conversion, or null
Throws:
IllegalArgumentException - when the profile sequence does not specify a well-defined color conversion
NullPointerException - if profiles is null
Method Detail

getICC_Profiles

public final ICC_Profile[] getICC_Profiles()
Returns the array of ICC_Profiles used to construct this ColorConvertOp. Returns null if the ColorConvertOp was not constructed from such an array.

Returns:
the array of ICC_Profile objects of this ColorConvertOp, or null if this ColorConvertOp was not constructed with an array of ICC_Profile objects.

filter

public final BufferedImage filter(BufferedImage src,
                                  BufferedImage dest)
ColorConverts the source BufferedImage. If the destination image is null, a BufferedImage will be created with an appropriate ColorModel.

Specified by:
filter in interface BufferedImageOp
Parameters:
src - the source BufferedImage to be converted
dest - the destination BufferedImage, or null
Returns:
dest color converted from src or a new, converted BufferedImage if dest is null
Throws:
IllegalArgumentException - if dest is null and this op was constructed using the constructor which takes only a RenderingHints argument, since the operation is ill defined.

filter

public final WritableRaster filter(Raster src,
                                   WritableRaster dest)
ColorConverts the image data in the source Raster. If the destination Raster is null, a new Raster will be created. The number of bands in the source and destination Rasters must meet the requirements explained above. The constructor used to create this ColorConvertOp must have provided enough information to define both source and destination color spaces. See above. Otherwise, an exception is thrown.

Specified by:
filter in interface RasterOp
Parameters:
src - the source Raster to be converted
dest - the destination WritableRaster, or null
Returns:
dest color converted from src or a new, converted WritableRaster if dest is null
Throws:
IllegalArgumentException - if the number of source or destination bands is incorrect, the source or destination color spaces are undefined, or this op was constructed with one of the constructors that applies only to operations on BufferedImages.

getBounds2D

public final Rectangle2D getBounds2D(BufferedImage src)
Returns the bounding box of the destination, given this source. Note that this will be the same as the the bounding box of the source.

Specified by:
getBounds2D in interface BufferedImageOp
Parameters:
src - the source BufferedImage
Returns:
a Rectangle2D that is the bounding box of the destination, given the specified src

getBounds2D

public final Rectangle2D getBounds2D(Raster src)
Returns the bounding box of the destination, given this source. Note that this will be the same as the the bounding box of the source.

Specified by:
getBounds2D in interface RasterOp
Parameters:
src - the source Raster
Returns:
a Rectangle2D that is the bounding box of the destination, given the specified src

createCompatibleDestImage

public BufferedImage createCompatibleDestImage(BufferedImage src,
                                               ColorModel destCM)
Creates a zeroed destination image with the correct size and number of bands, given this source.

Specified by:
createCompatibleDestImage in interface BufferedImageOp
Parameters:
src - Source image for the filter operation.
destCM - ColorModel of the destination. If null, an appropriate ColorModel will be used.
Returns:
a BufferedImage with the correct size and number of bands from the specified src.
Throws:
IllegalArgumentException - if destCM is null and this ColorConvertOp was created without any ICC_Profile or ColorSpace defined for the destination

createCompatibleDestRaster

public WritableRaster createCompatibleDestRaster(Raster src)
Creates a zeroed destination Raster with the correct size and number of bands, given this source.

Specified by:
createCompatibleDestRaster in interface RasterOp
Parameters:
src - the specified Raster
Returns:
a WritableRaster with the correct size and number of bands from the specified src
Throws:
IllegalArgumentException - if this ColorConvertOp was created without sufficient information to define the dst and src color spaces

getPoint2D

public final Point2D getPoint2D(Point2D srcPt,
                                Point2D dstPt)
Returns the location of the destination point given a point in the source. If dstPt is non-null, it will be used to hold the return value. Note that for this class, the destination point will be the same as the source point.

Specified by:
getPoint2D in interface BufferedImageOp
Specified by:
getPoint2D in interface RasterOp
Parameters:
srcPt - the specified source Point2D
dstPt - the destination Point2D
Returns:
dstPt after setting its location to be the same as srcPt

getRenderingHints

public final RenderingHints getRenderingHints()
Returns the rendering hints used by this op.

Specified by:
getRenderingHints in interface BufferedImageOp
Specified by:
getRenderingHints in interface RasterOp
Returns:
the RenderingHints object of this ColorConvertOp

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-2219
Document créé le 31/08/06 00:48, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/awt/image/ColorConvertOp.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,54 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Le cercle est le plus long chemin d'un point au même point.

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