====== Image ====== Cet objet représente une image. **Attention, cette page n'est pas complètement traduite. Voir la version originale : [[en:code:core:image]]** ===== Fonctions ===== ==== Image ==== Fonction constructeur. === Syntaxe === var monObjet = new Image(); var monObjet = new Image(autreImage); var monObjet = new Image(x, y); === Arguments === - autreImage - (Image) l'autre Image à copier === Exceptions === * (ParameterTypeError) type de paramètre incorrect * (ParameterCountError) compte de paramètre incorrect === Exemple === Créer une nouvelle image vide. var monObjet = new Image(); Créer une Image représentant une copie de ** autreImage **. var monObjet = new Image(autreImage); ==== takeScreenshot ==== Prend une capture d'écran de l'écran entier ou seulement de la ** fenêtre ** et conserve le résultat dans une nouvelle Image. === Syntaxe === var monObjet = Image.takeScreenshot(); var monObjet = Image.takeScreenshot(fenêtre); === Arguments === - fenêtre - ([[en:code:core:window|Window]]) la fenêtre dont vous voulez capturer une image === Exceptions === * (InvalidWindowError) fenêtre invalide [TODO:Translate] ==== takeScreenshotUsingScreenIndex ==== Take a screenshot of one screen and store the result in a new Image. [//Added in Actionaz 3.7.0.//] === Syntax === var myObject = Image.takeScreenshotUsingScreenIndex(0); === Arguments === - screenIndex - (integer) the index of the screen to screenshot === Exceptions === * (InvalidScreenIndexError) invalid screen index ===== Méthodes ===== ==== clone ==== Rend une copie de cette Image. === Syntaxe === monObjet.clone(); === Renvoie === * (Image) une copie de cette Image === Exemple === var copieDeMonObjet = monObjet.clone(); ==== equals ==== Renvoie vrai si cette Image et un autre se réfèrent à la même image. === Syntaxe === monObjet.equals(autre); === Arguments === - autre - (Image) une autre Image === Renvoie === * (bool) vrai si **autre** se réfère à la même image === Exemple === if(monPremierObjet.equals(monDeuxièmeObjet)) //Faire quelque chose ==== toString ==== Retourne une chaîne représentant cette Image. === Syntaxe === monObjet.toString(); === Renvoie === * (string) une chaîne représentant cette Image. === Exemple === Console.print(monObjet.toString()); === Notes === On appelle automatiquement cette méthode en essayant de convertir une Image en chaîne. ==== setData ==== Met les données de cette Image. === Syntaxe === monObjet.setData(data); === Arguments === - data - ([[en:code:core:rawdata|RawData]]) RawData de l'image === Renvoie === * (Image) cette image === Exceptions === * (ImageDataError) données d'image invalide === Notes === Les formats d'image soutenus sont BMP, GIF, JPG, JPEG, PNG, PBM, PGM, PPM, TIFF, XBM et XPM. ==== data ==== Rend les données de cette Image comme [[en:code:core:rawdata|RawData]] dans le format de BMP. === Syntaxe === monObjet.data(); === Renvoie === * ([[en:code:core:rawdata|RawData]]) cette Image comme RawData === Exceptions === * (ImageDataError) incapable de recevoir les données d'image ==== loadFromFile ==== Charge l'Image d'un dossier. === Syntaxe === monObjet.loadFromFile(nomDeFichier ); === Arguments === - nomDeFichier - (string) le nom du fichier à charger === Renvoie === * (Image) cette image === Exceptions === * (LoadImageError) incapable de charger l'image === Notes === Les formats d'image soutenus sont BMP, GIF, JPG, JPEG, PNG, PBM, PGM, PPM, TIFF, XBM et XPM. ==== saveToFile ==== Enregistre l'image dans un fichier. === Syntaxe === monObjet.saveToFile(nomDeFichier); === Arguments === - nomDeFichier - (string) nom de fichier à enregistrer dans === Renvoie === * (Image) cette image === Exceptions === * (SaveImageError) incapable de sauver l'image === Notes === Les formats d'image soutenus sont BMP, JPG, JPEG, PNG, PPM, TIFF, XBM et XPM. ==== applyFilter ==== Applique un filtre sur cette Image. === Syntaxe === monObjet.applyFilter(filtre); monObject.applyFilter(filtre, options); === Arguments === - filtre - ([[#filter|Filtre]]) le filtre à utiliser - options - (objet) option de filtre * filterChannels - (chaîne) la couleur sur laquelle sera appliquée le filtre. Une chaîne de caractères constituée de zéro ou une occurence des caractères r,g,b,a * filterBorderPolicy - (string) utilisé avec le filtre de convolution. Les valeurs sont "mirror", "extend" ou "wrap" * convolutionDivisor - (integer) le diviseur de convolution * convolutionBias - (integer) le biais de convolution * radius - (number) le radius * force - (number) la force (Utilise la, Luc!) * center - (object) le centre * x - (integer) la coordonnée x * y - (integer) la coordonnée y === Renvoie === * (Image) cette image === Exceptions === * (ApplyFilterError) incapable d'appliquer le filtre [TODO:Translate] ==== pixel ==== Returns a pixel from this Image. === Syntax === myObject.pixel(x, y); === Arguments === - x - (integer) x coordinate of the pixel to return - y - (integer) y coordinate of the pixel to return === Returns === * ([[en:code:core:color|Color]]) the pixel ==== setPixel ==== Sets a pixel from this Image. === Syntax === myObject.pixel(x, y, color); myObject.pixel(x, y, colorString); myObject.pixel(x, y, red, green, blue); === Arguments === - x - (integer) x coordinate of the pixel to set - y - (integer) y coordinate of the pixel to set - color - ([[en:code:core:color|Color]]) color of the pixel to set - red - (integer) red value of the color to set - green - (integer) green value of the color to set - blue - (integer) blue value of the color to set === Returns === * (Image) this Image ==== mirror ==== Mirror this Image. === Syntax === myObject.mirror(mirrorOrientation); === Arguments === - mirrorOrientation - ([[#mirrororientation|MirrorOrientation]]) mirror orientation === Returns === * (Image) this Image ==== setSize ==== Resizes this Image. === Syntax === myObject.setSize(size); myObject.setSize(width, height); === Arguments === - size - ([[en:code:core:size|Size]]) the new Image size - width - (integer) the new width of this Image - height - (integer) the new height of this Image === Returns === * (Image) this Image ==== size ==== Returns the size of this Image. === Syntax === myObject.size(); === Returns === * ([[en:code:core:size|Size]]) the size of this Image ==== width ==== Returns the width of this Image. === Syntax === myObject.width(); === Returns === * (integer) the width of this Image ==== height ==== Returns the height of this Image. === Syntax === myObject.height(); === Returns === * (integer) the height of this Image ==== copy ==== Returns a copy of this Image or only a part of it. === Syntax === myObject.copy(); myObject.copy(rect); === Arguments === - rect - ([[en:code:core:rect|Rect]]) the section of this Image to copy === Returns === * (Image) a new copy of this Image ==== findSubImage ==== Searches for another image contained in this one. //Added in Actionaz 3.0.1.// === Syntax === myObject.findSubImage(otherImage); myObject.findSubImage(otherImage, options); === Arguments === - otherImage - (Image) the Image to find - options - (object) search options * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70) * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2) * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient) [//Added in Actionaz 3.7.0.//] === Returns === * (object) the matching point, or null if no matching point can be found * position - ([[en:code:core:point|Point]]) the matching image center * confidence - (integer) the confidence percentage === Exceptions === * (FindSubImageError) an error occured while searching for a sub-image * (ParameterTypeError) incorrect parameter type === Example === //Searches for an object on the screen var screenShot = Image.takeScreenshot(); var imageToFind = new Image("object.png"); var searchResult = screenShot.findSubImage(imageToFind); if(searchResult) Console.print("Matching image found, position: " + searchResult.position + ", confidence: " + searchResult.confidence); else Console.print("No matching image found."); ==== findSubImages ==== Searches for images contained in this one. //Added in Actionaz 3.0.1.// === Syntax === myObject.findSubImages(otherImage); myObject.findSubImages(otherImage, options); === Arguments === - otherImage - (Image) the Image to find - options - (object) search options * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70) * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2) * searchExpansion - (integer) the number of pixels to shift when searching for another matching image (default: 15) * maximumMatches - (integer) the maximal number of matches (default: 10) * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient) [//Added in Actionaz 3.7.0.//] === Returns === * (array of objects) the matching points, or null if no matching point can be found * position - ([[en:code:core:point|Point]]) the matching image center * confidence - (integer) the confidence percentage === Exceptions === * (FindSubImageError) an error occured while searching for a sub-image * (ParameterTypeError) incorrect parameter type === Example === //Searches for objects on the screen var screenShot = Image.takeScreenshot(); var imageToFind = new Image("object.png"); var searchResult = screenShot.findSubImages(imageToFind); if(searchResult) { Console.print("Matching images found\n"); for(var i = 0; i < searchResult.length; ++i) { Console.print("position: " + searchResult[i].position + ", confidence: " + searchResult[i].confidence + "\n"); } } else Console.print("No matching images found."); ==== findSubImageAsync ==== Searches for another image contained in this one in asynchronous mode. //Added in Actionaz 3.0.1.// === Syntax === myObject.findSubImageAsync(otherImage, callback); myObject.findSubImageAsync(otherImage, callback, options); === Arguments === - otherImage - (Image) the Image to find - callback(object) - (function) the function that will be called when the search ends * position - ([[en:code:core:point|Point]]) the matching image center * confidence - (integer) the confidence percentage - options - (object) search options * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70) * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2) * searchExpansion - (integer) the number of pixels to shift when searching for another matching image (default: 15) * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient) [//Added in Actionaz 3.7.0.//] === Returns === * (Image) this Image === Exceptions === * (FindSubImageError) an error occured while searching for a sub-image * (ParameterTypeError) incorrect parameter type === Example === //Searches for an object on the screen var screenShot = Image.takeScreenshot(); var imageToFind = new Image("object.png"); screenShot.findSubImageAsync(imageToFind, function(searchResult) { if(searchResult) Console.print("Matching image found, position: " + searchResult.position + ", confidence: " + searchResult.confidence); else Console.print("No matching image found."); }); ==== findSubImagesAsync ==== Searches for images contained in this one in asynchronous mode. //Added in Actionaz 3.0.1.// === Syntax === myObject.findSubImagesAsync(otherImage, callback); myObject.findSubImagesAsync(otherImage, callback, options); === Arguments === - otherImage - (Image) the Image to find - callback(object) - (function) the function that will be called when the search ends * position - ([[en:code:core:point|Point]]) the matching image center * confidence - (integer) the confidence percentage - options - (object) search options * confidenceMinimum - (integer) the minimum confidence percentage, 100 means perfect match (default: 70) * downPyramidCount - (integer) the number of pyramids to use. A pyramid is a subdivision of the image used to accelerate the search. Choose 1 here if the searched image is not very different from this image. (default: 2) * searchExpansion - (integer) the number of pixels to shift when searching for another matching image (default: 15) * maximumMatches - (integer) the maximal number of matches (default: 10) * method - ([[#method|Method]]) the search method to use (default: CorrelationCoefficient) [//Added in Actionaz 3.7.0.//] === Returns === * (Image) this Image === Exceptions === * (FindSubImageError) an error occured while searching for a sub-image * (ParameterTypeError) incorrect parameter type === Example === //Searches for objects on the screen var screenShot = Image.takeScreenshot(); var imageToFind = new Image("object.png"); screenShot.findSubImagesAsync(imageToFind, function(searchResult) { if(searchResult) { Console.print("Matching images found\n"); for(var i = 0; i < searchResult.length; ++i) { Console.print("position: " + searchResult[i].position + ", confidence: " + searchResult[i].confidence + "\n"); } } else Console.print("No matching images found."); }); ===== Enumerations ===== ==== Filter ==== Image filters. === Values === - ConvolutionFilter: the convolution filter - GaussianBlur: a gaussian blur - Defocus: blurs the image - Highlight: highlight the image - Sharpen: sharpens the image - SharpenMore: sharpens the image - SharpenEvenMore: sharpens the image - EdgeDetect: edge detection filter - BigEdge: edge detection filter (thicker edges) - Emboss: embosses the image (no color preservation) - EmbossColor: embosses the image (color preservation) - Negative: negates a color channel - RemoveChannel: remove a color channel - Punch: distorts the image ==== MirrorOrientation ==== Mirror orientation. === Values === - Vertical: a vertical mirror - Horizontal: an horizontal mirror ==== Method ==== Search method. [//Added in Actionaz 3.7.0.//] === Values === - CorrelationCoefficient: correlation coefficient, best for most use cases - CrossCorrelation: cross correlation - SquaredDifference: squared difference