Zurück   Flashforum > Flash > ActionScript > ActionScript 3

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 20-02-2011, 11:10   #1 (permalink)
Animateur
 
Benutzerbild von Master Wu
 
Registriert seit: Jan 2003
Ort: MZ
Beiträge: 1.536
BitmapData ... transparenz "stanzen"

EDIT: gerade komm ich selber auf ne Idee ... BLENDMODE!!!!
So sollte es doch klappen, ich tests mal, sorry schonmal



Moin, mal wieder ne recht spezielle Frage:

- Ich hab eine BitmapData, die mit farbigen pixeln gefüllt ist.
- Nun will ich einen Kreis da "rausstanzen", der also dann transparent sein soll.

mit BitmapData.draw könnte man super einen Kreis, den man vorher in einen Sprite gemalen hat, da reinkopieren, nur hab ich keine Idee, wie man da ein transparentes "Loch" reinkopieren kann?

Ich hab dann einen weissen Kreis reinkopiert und wollte den dann per BitmapData.threshold auf Transparent stellen.
Geht prinzipiell, aber ich bekomme keine weichen Kanten hin, threshold macht entweder voll transparent oder garnix.

Ich habs jetzt mal temporär so gelöst, dass ich per getPixel32 und setPixel32 bei solchen Pixeln, die nicht komplett schwarz sind, den Grauwert als Alphawert einsetze. Es geht hierbei um eine Maske. Also ich wandle praktisch eine s/w-maske in eine alpha-Maske um.

Die Pixel-für-Pixel Variante ist leider sehr performancefressend.
Man könnte es wohl mit einem custom Pixelbender-Filter beschleunigen, trotzdem meine Frage, ob es nicht auch einen sauberen schnellen Weg per BitmapData-Befehlen gibt, um transparente Löcher ins BMD zu stanzen, auf den ich nur nicht komme

Hoffe der Post ist nicht zu verwirrend, danke schonmal für eure Anregungen
__________________
there is no way to happiness, happiness is the way - flashgames

Geändert von Master Wu (20-02-2011 um 11:12 Uhr)
Master Wu ist offline   Mit Zitat antworten
Alt 20-02-2011, 15:21   #2 (permalink)
in the boondocks
 
Benutzerbild von shin10
 
Registriert seit: Feb 2006
Ort: Augsburg
Beiträge: 3.496
hi,

sollte so klappen
PHP-Code:
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.display.BlendMode;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.display.Shape;
import flash.geom.Point;
import flash.geom.ColorTransform;

var 
bmpdPic:BitmapData = new BitmapData(mcBild.width,mcBild.height,true,0);
bmpdPic.draw(mcBild);
var 
bmpPic:Bitmap = new Bitmap(bmpdPic);
addChild(bmpPic);

var 
c:Shape = new Shape();
c.graphics.beginFill(0xFFFFFF1);
c.graphics.drawRect(00200200);
c.graphics.drawCircle(505050);
c.graphics.endFill();

var 
bmpdCircle:BitmapData = new BitmapData(bmpdPic.width,bmpdPic.height,true,0);
bmpdCircle.draw(c);
bmpdPic.copyChannel(bmpdCirclebmpdCircle.rect, new Point(c.xc.y), BitmapDataChannel.ALPHABitmapDataChannel.ALPHA); 
mfg

sx
__________________

flintfabrik.de
shin10 ist offline   Mit Zitat antworten
Alt 20-02-2011, 15:26   #3 (permalink)
Animateur
 
Benutzerbild von Master Wu
 
Registriert seit: Jan 2003
Ort: MZ
Beiträge: 1.536
Ah, BitmapDataChannel ... auch ne gute Idee!
Dankeschön!
__________________
there is no way to happiness, happiness is the way - flashgames
Master Wu ist offline   Mit Zitat antworten
Alt 20-02-2011, 16:08   #4 (permalink)
in the boondocks
 
Benutzerbild von shin10
 
Registriert seit: Feb 2006
Ort: Augsburg
Beiträge: 3.496
zumindest werden die kanten sauberer als mit BlendMode.ERASE, der wohl ohne anti-aliaste kanten arbeitet. oder bist du da noch auf was anderes gestoßen?
__________________

flintfabrik.de
shin10 ist offline   Mit Zitat antworten
Alt 20-02-2011, 16:47   #5 (permalink)
Animateur
 
Benutzerbild von Master Wu
 
Registriert seit: Jan 2003
Ort: MZ
Beiträge: 1.536
ERASE funzt auch, du musst aber erst die "Stanzform" in eine BitmapData "drawen", und das daraus erstellte Bitmap dann per ERASE in die andere BitmapData "drawen"

Direkt nen Sprite oder so per ERASE reinmalen killt das AntiAliasing.




PHP-Code:
package  
{
    
import flash.display.Sprite;
    
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.display.BlendMode;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.display.Shape;
import flash.geom.Point;
import flash.geom.ColorTransform
    
/**
     * ...
     * @author me
     * 
     */
    
public class BlendModeTests extends Sprite
    
{
        
        private var 
_imgBmd:BitmapData;
        private var 
_stanzBmd:BitmapData;
        
        public function 
BlendModeTests() 
        {
            
            
_imgBmd = new BitmapData(10001000true0x00000000);
            
            
_imgBmd.floodFill(000xffff0000);
            var 
imgBm:Bitmap = new Bitmap(_imgBmd);
            
//imgBm.blendMode = BlendMode.LAYER;
            
addChild(imgBm);
            
            var 
spr:Sprite = new Sprite();
            
spr.graphics.beginFill(0xffff00001);
            
spr.graphics.drawCircle(10010040);
            
            
_stanzBmd = new BitmapData(400400true0x00000000);
            
_stanzBmd.draw(spr);
            var 
stanzBm:Bitmap = new Bitmap(_stanzBmd);
            
            
            
_imgBmd.draw(stanzBmnullnullBlendMode.ERASE);
        
            
        }
        
    }


__________________
there is no way to happiness, happiness is the way - flashgames
Master Wu ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
"spiegeln" eines mcs per BitmapData -> asynchron Zett Flash CS3 Professional 3 21-08-2008 14:46
Transparenz in einer "Interop.ShockwaveFlashObjects"-Komponente Vader2108 Alternative Technologien 4 09-05-2008 16:26
BitmapData.threshold - Schwarze "Ränder" abschneiden / makieren Hamberger ActionScript 2 2 29-03-2007 11:45
Wo ist find ich die Leiste mit "Normal", "Darüber", "Gedrückt" und "Aktiv" maggi198 Flash Einsteiger 2 19-10-2006 21:33
transparenz in "netscape" und "linux" heinzi123 Flash MX 1 24-09-2002 19:59


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:16 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele