public virtual void drawBitmap(AsBitmapData bitmap, float alpha)
 {
     if (bitmap.Texture != null)
     {
         BcRenderSupport.DrawImage(bitmap.Texture, 0, 0);
     }
 }
 public static AsTexture getTexture()
 {
     AsBitmapData bmpData = new AsBitmapData(BITMAP_WIDTH, BITMAP_HEIGHT);
     AsByteArray bmpBytes = new AsByteArray();
     int numBytes = (int)(BITMAP_DATA.getLength());
     int i = 0;
     for (; i < numBytes; ++i)
     {
         bmpBytes.writeUnsignedInt((uint)(BITMAP_DATA[i]));
     }
     bmpBytes.uncompress();
     bmpData.setPixels(new AsRectangle(0, 0, BITMAP_WIDTH, BITMAP_HEIGHT), bmpBytes);
     return AsTexture.fromBitmapData(bmpData, false);
 }
Пример #3
0
        public virtual void load(AsURLRequest request, AsLoaderContext context)
        {
            mRequest = request;
            String url = request.getUrl();

            if (url.StartsWith("http"))
            {
                throw new NotImplementedException("Http loading not implemented");
            }

            BcTexture2D image = BcResFactory.GetInstance().LoadImage(url);
            AsDebug.assert(image != null, url);

            AsBitmapData bitmapData = new AsBitmapData(image);
            mContent = new AsBitmap(bitmapData);

            Debug.WriteLine("Image loaded: " + url);
            dispatchEvent(new AsEvent(AsEvent.COMPLETE));
        }
Пример #4
0
        public virtual void load(AsURLRequest request, AsLoaderContext context)
        {
            mRequest = request;
            String url = request.getUrl();

            if (url.StartsWith("http"))
            {
                throw new NotImplementedException("Http loading not implemented");
            }

            BcTexture2D image = BcResFactory.GetInstance().LoadImage(url);

            AsDebug.assert(image != null, url);

            AsBitmapData bitmapData = new AsBitmapData(image);

            mContent = new AsBitmap(bitmapData);

            Debug.WriteLine("Image loaded: " + url);
            dispatchEvent(new AsEvent(AsEvent.COMPLETE));
        }
Пример #5
0
 public static AsTexture fromColor(int width, int height, uint color, bool optimizeForRenderTexture, float scale)
 {
     if(scale <= 0)
     {
         scale = AsStarling.getContentScaleFactor();
     }
     AsBitmapData bitmapData = new AsBitmapData(width * scale, height * scale, true, color);
     AsTexture texture = fromBitmapData(bitmapData, false, optimizeForRenderTexture, scale);
     if(!AsStarling.getHandleLostContext())
     {
         bitmapData.dispose();
     }
     return texture;
 }
Пример #6
0
 public static AsTexture fromBitmapData(AsBitmapData data)
 {
     return fromBitmapData(data, true, false, 1);
 }
Пример #7
0
 public static AsTexture fromBitmapData(AsBitmapData data, bool generateMipMaps)
 {
     return fromBitmapData(data, generateMipMaps, false, 1);
 }
Пример #8
0
 public void uploadFromBitmapData(AsBitmapData source)
 {
     uploadFromBitmapData(source, (uint)(0));
 }
Пример #9
0
 private void createRenderedContents()
 {
     if(mQuadBatch != null)
     {
         mQuadBatch.removeFromParent(true);
         mQuadBatch = null;
     }
     float scale = AsStarling.getContentScaleFactor();
     float width = mHitArea.getWidth() * scale;
     float height = mHitArea.getHeight() * scale;
     AsTextFormat textFormat = new AsTextFormat(mFontName, mFontSize * scale, mColor, mBold, mItalic, mUnderline, null, null, mHAlign);
     textFormat.setKerning(mKerning);
     sNativeTextField.setDefaultTextFormat(textFormat);
     sNativeTextField.setWidth(width);
     sNativeTextField.setHeight(height);
     sNativeTextField.setAntiAliasType(AsAntiAliasType.ADVANCED);
     sNativeTextField.setSelectable(false);
     sNativeTextField.setMultiline(true);
     sNativeTextField.setWordWrap(true);
     sNativeTextField.setText(mText);
     sNativeTextField.setEmbedFonts(true);
     sNativeTextField.setOwnProperty("filters", mNativeFilters);
     if(sNativeTextField.getTextWidth() == 0.0f || sNativeTextField.getTextHeight() == 0.0f)
     {
         sNativeTextField.setEmbedFonts(false);
     }
     if(mAutoScale)
     {
         autoScaleNativeTextField(sNativeTextField);
     }
     float textWidth = sNativeTextField.getTextWidth();
     float textHeight = sNativeTextField.getTextHeight();
     float xOffset = 0.0f;
     if(mHAlign == AsHAlign.LEFT)
     {
         xOffset = 2;
     }
     else
     {
         if(mHAlign == AsHAlign.CENTER)
         {
             xOffset = (width - textWidth) / 2.0f;
         }
         else
         {
             if(mHAlign == AsHAlign.RIGHT)
             {
                 xOffset = width - textWidth - 2;
             }
         }
     }
     float yOffset = 0.0f;
     if(mVAlign == AsVAlign.TOP)
     {
         yOffset = 2;
     }
     else
     {
         if(mVAlign == AsVAlign.CENTER)
         {
             yOffset = (height - textHeight) / 2.0f;
         }
         else
         {
             if(mVAlign == AsVAlign.BOTTOM)
             {
                 yOffset = height - textHeight - 2;
             }
         }
     }
     AsBitmapData bitmapData = new AsBitmapData(width, height, true, 0x0);
     bitmapData.draw(sNativeTextField, new AsMatrix(1, 0, 0, 1, 0, ((int)(yOffset)) - 2));
     sNativeTextField.setText("");
     if(mTextBounds == null)
     {
         mTextBounds = new AsRectangle();
     }
     mTextBounds.setTo(xOffset / scale, yOffset / scale, textWidth / scale, textHeight / scale);
     AsTexture texture = AsTexture.fromBitmapData(bitmapData, false, false, scale);
     if(mImage == null)
     {
         mImage = new AsImage(texture);
         mImage.setTouchable(false);
         addChild(mImage);
     }
     else
     {
         mImage.getTexture().dispose();
         mImage.setTexture(texture);
         mImage.readjustSize();
     }
 }
Пример #10
0
 public AsBitmap(AsBitmapData bitmapData)
     : this(bitmapData, "auto", false)
 {
 }
Пример #11
0
 public AsBitmap(AsBitmapData bitmapData, String pixelSnapping, bool smoothing)
 {
     mBitmapData    = bitmapData;
     mPixelSnapping = pixelSnapping;
     mSmoothing     = smoothing;
 }
Пример #12
0
 public AsBitmap(AsBitmapData bitmapData)
     : this(bitmapData, "auto", false)
 {
 }
Пример #13
0
 public AsBitmap(AsBitmapData bitmapData, String pixelSnapping)
     : this(bitmapData, pixelSnapping, false)
 {
 }
Пример #14
0
 public AsBitmap(AsBitmapData bitmapData, String pixelSnapping, bool smoothing)
 {
     mBitmapData = bitmapData;
     mPixelSnapping = pixelSnapping;
     mSmoothing = smoothing;
 }
Пример #15
0
 public virtual void setBitmapData(AsBitmapData _value)
 {
     mBitmapData = _value;
 }
Пример #16
0
 public void copyPixels(AsBitmapData data, AsRectangle asRectangle, AsPoint sOrigin)
 {
     throw new NotImplementedException();
 }
Пример #17
0
 public void drawBitmap(AsBitmapData bitmap, float x, float y)
 {
 }
Пример #18
0
 public static void uploadBitmapData(bc.flash.display3D.textures.AsTexture nativeTexture, AsBitmapData data, bool generateMipmaps)
 {
     nativeTexture.uploadFromBitmapData(data);
     if(generateMipmaps && data.getWidth() > 1 && data.getHeight() > 1)
     {
         int currentWidth = data.getWidth() >> 1;
         int currentHeight = data.getHeight() >> 1;
         int level = 1;
         AsBitmapData canvas = new AsBitmapData(currentWidth, currentHeight, true, 0);
         AsMatrix transform = new AsMatrix(.5f, 0, 0, .5f);
         AsRectangle bounds = new AsRectangle();
         while(currentWidth >= 1 || currentHeight >= 1)
         {
             bounds.width = currentWidth;
             bounds.height = currentHeight;
             canvas.fillRect(bounds, (uint)(0));
             canvas.draw(data, transform, null, null, null, true);
             nativeTexture.uploadFromBitmapData(canvas, (uint)(level++));
             transform.scale(0.5f, 0.5f);
             currentWidth = currentWidth >> 1;
             currentHeight = currentHeight >> 1;
         }
         canvas.dispose();
     }
 }
Пример #19
0
 public virtual void setBitmapData(AsBitmapData _value)
 {
     mBitmapData = _value;
 }
 public virtual void drawBitmap(AsBitmapData bitmap, float alpha)
 {
     throw new AsNotImplementedError();
 }
Пример #21
0
 public AsBitmap(AsBitmapData bitmapData, String pixelSnapping)
     : this(bitmapData, pixelSnapping, false)
 {
 }
Пример #22
0
 public void drawBitmap(AsBitmapData bitmap, float x, float y)
 {
 }
Пример #23
0
 public virtual void drawToBitmapData(AsBitmapData destination)
 {
     throw new AsNotImplementedError();
 }
Пример #24
0
 public void copyPixels(AsBitmapData data, AsRectangle asRectangle, AsPoint sOrigin)
 {
     throw new NotImplementedException();
 }
Пример #25
0
 public static AsTexture fromBitmapData(AsBitmapData data, bool generateMipMaps, bool optimizeForRenderTexture, float scale)
 {
     int origWidth = data.getWidth();
     int origHeight = data.getHeight();
     int legalWidth = AsGlobal.getNextPowerOfTwo(origWidth);
     int legalHeight = AsGlobal.getNextPowerOfTwo(origHeight);
     AsContext3D context = AsStarling.getContext();
     AsBitmapData potData = null;
     if(context == null)
     {
         throw new AsMissingContextError();
     }
     bc.flash.display3D.textures.AsTexture nativeTexture = context.createTexture(legalWidth, legalHeight, AsContext3DTextureFormat.BGRA, optimizeForRenderTexture);
     if(legalWidth > origWidth || legalHeight > origHeight)
     {
         potData = new AsBitmapData(legalWidth, legalHeight, true, 0);
         potData.copyPixels(data, data.getRect(), sOrigin);
         data = potData;
     }
     uploadBitmapData(nativeTexture, data, generateMipMaps);
     AsConcreteTexture concreteTexture = new AsConcreteTexture(nativeTexture, AsContext3DTextureFormat.BGRA, legalWidth, legalHeight, generateMipMaps, true, optimizeForRenderTexture, scale);
     if(AsStarling.getHandleLostContext())
     {
         concreteTexture.restoreOnLostContext(data);
     }
     else
     {
         if(potData != null)
         {
             potData.dispose();
         }
     }
     if(origWidth == legalWidth && origHeight == legalHeight)
     {
         return concreteTexture;
     }
     else
     {
         return new AsSubTexture(concreteTexture, new AsRectangle(0, 0, origWidth / scale, origHeight / scale), true);
     }
 }
Пример #26
0
 public void uploadFromBitmapData(AsBitmapData source, uint miplevel)
 {
     throw new AsNotImplementedError();
 }
Пример #27
0
 public static AsTexture fromBitmapData(AsBitmapData data, bool generateMipMaps, bool optimizeForRenderTexture)
 {
     return fromBitmapData(data, generateMipMaps, optimizeForRenderTexture, 1);
 }
 public void uploadFromBitmapData(AsBitmapData source, uint side, uint miplevel)
 {
 }