API java : RGBImageFilter


java.awt.image
Class RGBImageFilter

java.lang.Object
  extended by java.awt.image.ImageFilter
      extended by java.awt.image.RGBImageFilter
All Implemented Interfaces:
ImageConsumer, Cloneable
Direct Known Subclasses:
GrayFilter

public abstract class RGBImageFilter
extends ImageFilter

This class provides an easy way to create an ImageFilter which modifies the pixels of an image in the default RGB ColorModel. It is meant to be used in conjunction with a FilteredImageSource object to produce filtered versions of existing images. It is an abstract class that provides the calls needed to channel all of the pixel data through a single method which converts pixels one at a time in the default RGB ColorModel regardless of the ColorModel being used by the ImageProducer. The only method which needs to be defined to create a useable image filter is the filterRGB method. Here is an example of a definition of a filter which swaps the red and blue components of an image:

  1. class RedBlueSwapFilter extends RGBImageFilter {
  2. public RedBlueSwapFilter() {
  3. // The filter's operation does not depend on the
  4. // pixel's location, so IndexColorModels can be
  5. // filtered directly.
  6. canFilterIndexColorModel = true;
  7. }
  8.  
  9. public int filterRGB(int x, int y, int rgb) {
  10. return ((rgb & 0xff00ff00)
  11. | ((rgb & 0xff0000) >> 16)
  12. | ((rgb & 0xff) << 16));
  13. }
  14. }

See Also:
FilteredImageSource, ImageFilter, ColorModel.getRGBdefault()

Field Summary
protected  boolean canFilterIndexColorModel
          This boolean indicates whether or not it is acceptable to apply the color filtering of the filterRGB method to the color table entries of an IndexColorModel object in lieu of pixel by pixel filtering.
protected  ColorModel newmodel
          The ColorModel with which to replace origmodel when the user calls substituteColorModel.
protected  ColorModel origmodel
          The ColorModel to be replaced by newmodel when the user calls substituteColorModel.
 
Fields inherited from class java.awt.image.ImageFilter
consumer
 
Fields inherited from interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
 
Constructor Summary
RGBImageFilter()
           
 
Method Summary
 IndexColorModel filterIndexColorModel(IndexColorModel icm)
          Filters an IndexColorModel object by running each entry in its color tables through the filterRGB function that RGBImageFilter subclasses must provide.
abstract  int filterRGB(int x, int y, int rgb)
          Subclasses must specify a method to convert a single input pixel in the default RGB ColorModel to a single output pixel.
 void filterRGBPixels(int x, int y, int w, int h, int[] pixels, int off, int scansize)
          Filters a buffer of pixels in the default RGB ColorModel by passing them one by one through the filterRGB method.
 void setColorModel(ColorModel model)
          If the ColorModel is an IndexColorModel and the subclass has set the canFilterIndexColorModel flag to true, we substitute a filtered version of the color model here and wherever that original ColorModel object appears in the setPixels methods.
 void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)
          If the ColorModel object is the same one that has already been converted, then simply passes the pixels through with the converted ColorModel.
 void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)
          If the ColorModel object is the same one that has already been converted, then simply passes the pixels through with the converted ColorModel, otherwise converts the buffer of integer pixels to the default RGB ColorModel and passes the converted buffer to the filterRGBPixels method to be converted one by one.
 void substituteColorModel(ColorModel oldcm, ColorModel newcm)
          Registers two ColorModel objects for substitution.
 
Methods inherited from class java.awt.image.ImageFilter
clone, getFilterInstance, imageComplete, resendTopDownLeftRight, setDimensions, setHints, setProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

origmodel

protected ColorModel origmodel
The ColorModel to be replaced by newmodel when the user calls substituteColorModel.


newmodel

protected ColorModel newmodel
The ColorModel with which to replace origmodel when the user calls substituteColorModel.


canFilterIndexColorModel

protected boolean canFilterIndexColorModel
This boolean indicates whether or not it is acceptable to apply the color filtering of the filterRGB method to the color table entries of an IndexColorModel object in lieu of pixel by pixel filtering. Subclasses should set this variable to true in their constructor if their filterRGB method does not depend on the coordinate of the pixel being filtered.

See Also:
substituteColorModel(java.awt.image.ColorModel, java.awt.image.ColorModel), filterRGB(int, int, int), IndexColorModel
Constructor Detail

RGBImageFilter

public RGBImageFilter()
Method Detail

setColorModel

public void setColorModel(ColorModel model)
If the ColorModel is an IndexColorModel and the subclass has set the canFilterIndexColorModel flag to true, we substitute a filtered version of the color model here and wherever that original ColorModel object appears in the setPixels methods. If the ColorModel is not an IndexColorModel or is null, this method overrides the default ColorModel used by the ImageProducer and specifies the default RGB ColorModel instead.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

Specified by:
setColorModel in interface ImageConsumer
Overrides:
setColorModel in class ImageFilter
Parameters:
model - the specified ColorModel
See Also:
ImageConsumer, ColorModel.getRGBdefault()

substituteColorModel

public void substituteColorModel(ColorModel oldcm,
                                 ColorModel newcm)
Registers two ColorModel objects for substitution. If the oldcm is encountered during any of the setPixels methods, the newcm is substituted and the pixels passed through untouched (but with the new ColorModel object).

Parameters:
oldcm - the ColorModel object to be replaced on the fly
newcm - the ColorModel object to replace oldcm on the fly

filterIndexColorModel

public IndexColorModel filterIndexColorModel(IndexColorModel icm)
Filters an IndexColorModel object by running each entry in its color tables through the filterRGB function that RGBImageFilter subclasses must provide. Uses coordinates of -1 to indicate that a color table entry is being filtered rather than an actual pixel value.

Parameters:
icm - the IndexColorModel object to be filtered
Returns:
a new IndexColorModel representing the filtered colors
Throws:
NullPointerException - if icm is null

filterRGBPixels

public void filterRGBPixels(int x,
                            int y,
                            int w,
                            int h,
                            int[] pixels,
                            int off,
                            int scansize)
Filters a buffer of pixels in the default RGB ColorModel by passing them one by one through the filterRGB method.

Parameters:
x, y - the coordinates of the upper-left corner of the region of pixels
w - the width of the region of pixels
h - the height of the region of pixels
pixels - the array of pixels
off - the offset into the pixels array
scansize - the distance from one row of pixels to the next in the array
See Also:
ColorModel.getRGBdefault(), filterRGB(int, int, int)

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel model,
                      byte[] pixels,
                      int off,
                      int scansize)
If the ColorModel object is the same one that has already been converted, then simply passes the pixels through with the converted ColorModel. Otherwise converts the buffer of byte pixels to the default RGB ColorModel and passes the converted buffer to the filterRGBPixels method to be converted one by one.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

Specified by:
setPixels in interface ImageConsumer
Overrides:
setPixels in class ImageFilter
w - the width of the area of pixels
h - the height of the area of pixels
model - the specified ColorModel
pixels - the array of pixels
off - the offset into the pixels array
scansize - the distance from one row of pixels to the next in the pixels array
See Also:
ColorModel.getRGBdefault(), filterRGBPixels(int, int, int, int, int[], int, int)

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel model,
                      int[] pixels,
                      int off,
                      int scansize)
If the ColorModel object is the same one that has already been converted, then simply passes the pixels through with the converted ColorModel, otherwise converts the buffer of integer pixels to the default RGB ColorModel and passes the converted buffer to the filterRGBPixels method to be converted one by one. Converts a buffer of integer pixels to the default RGB ColorModel and passes the converted buffer to the filterRGBPixels method.

Note: This method is intended to be called by the ImageProducer of the Image whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.

Specified by:
setPixels in interface ImageConsumer
Overrides:
setPixels in class ImageFilter
w - the width of the area of pixels
h - the height of the area of pixels
model - the specified ColorModel
pixels - the array of pixels
off - the offset into the pixels array
scansize - the distance from one row of pixels to the next in the pixels array
See Also:
ColorModel.getRGBdefault(), filterRGBPixels(int, int, int, int, int[], int, int)

filterRGB

public abstract int filterRGB(int x,
                              int y,
                              int rgb)
Subclasses must specify a method to convert a single input pixel in the default RGB ColorModel to a single output pixel.

Parameters:
x, y - the coordinates of the pixel
rgb - the integer pixel representation in the default RGB color model
Returns:
a filtered pixel in the default RGB color model.
See Also:
ColorModel.getRGBdefault(), filterRGBPixels(int, int, int, int, int[], int, int)

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-1875
Document créé le 30/08/06 23:49, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/awt/image/RGBImageFilter.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,47 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Chaque fois qu'un enfant dit : "Je ne crois pas aux fées", il y a quelque part une petite fée qui meurt.

James Barrie [Extrait de Peter Pan]
 
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)