Quelqu'un at-il un exemple d'utilisation de la fonction ImageSnapshot.captureBitmapData avec une matrice de rotation? Voici le code que je utilise:Impossible d'utiliser ImageSnapshot.captureBitmapData avec une matrice de rotation
var matrix:Matrix = new Matrix();
matrix.rotate(degreesToRadians(90));
var bitmapData:BitmapData = ImageSnapshot.captureBitmapData(textInput, matrix);
Mais malheureusement, cela jette une erreur sur la ligne suivante dans ImageSnapshot.as:
data = new BitmapData(scaledWidth, scaledHeight, true, 0x00000000); // <-- THROWS ERROR HERE AS scaledWidth/scaledHeight are extremely small numbers (-1-e16 etc)
data.draw(source, matrix, colorTransform,
blendMode, clipRect, smoothing);
}
finally
{
if (source is IUIComponent)
finishPrintObject(IUIComponent(source), normalState); // <-- ERROR THROWN HERE, BUT CAUSE OF ERROR IS ABOVE
}
Ce que je suis en train de réaliser est une image bitmap pivotée de un contrôle d'entrée de texte (j'essaie d'éviter d'incorporer une police dans l'application). Ce code fonctionne très bien lorsque je ne fais pas pivoter le bitmap, mais à la minute où je le fais pivoter, il se casse.
Post-Acceptée-réponse Modifier
je travaillais avec une classe de chargeur dans mon problème d'origine, et je voulais aussi le texte 270degrees - voici donc le texte qui fait que:
var matrix:Matrix = new Matrix();
matrix.rotate(Math.PI * 1.5);
matrix.translate(0, copyThis.width);
var bitmapData:BitmapData = ImageSnapshot.captureBitmapData(copyThis, new Matrix());
var rotatedBitmap : BitmapData = new BitmapData(bitmapData.height, bitmapData.width, false, 0xFFFF0000);
rotatedBitmap.draw(bitmapData, matrix);
loader.load(new Bitmap(rotatedBitmap));
Merci!
Vous monsieur, sont brillants :) J'ai essayé en utilisant un bitmap intermédiaire précédemment, mais je ne pouvais pas le faire fonctionner - il a été la traduction manquante! Si je pouvais attribuer plus de points pour la bonne réponse, je le ferais :) Merci! –