public void saveImage(object pSender) { using (var stream = new MemoryStream()) { m_pTarget.SaveToStream(stream, ImageFormat.PNG); //m_pTarget.saveToFile(jpg, ImageFormat.JPG); stream.Position = 0; Texture2D xnatex = Texture2D.FromStream(DrawManager.graphicsDevice, stream); var tex = new CCTexture2D(); tex.InitWithTexture(xnatex); CCSprite sprite = new CCSprite(tex); sprite.Scale = 0.3f; AddChild(sprite); sprite.Position = new CCPoint(40, 40); sprite.Rotation = counter * 3; } counter++; }
protected virtual bool InitWithWidthAndHeight(int w, int h, SurfaceFormat colorFormat, DepthFormat depthFormat, RenderTargetUsage usage) { w = (w * CCMacros.CCContentScaleFactor()); h = (h * CCMacros.CCContentScaleFactor()); m_pTexture = new CCTexture2D(); m_pTexture.SetAliasTexParameters(); m_pRenderTarget2D = DrawManager.CreateRenderTarget(w, h, colorFormat, depthFormat, usage); m_pTexture.InitWithTexture(m_pRenderTarget2D); m_bFirstUsage = true; m_pSprite = new CCSprite(m_pTexture); //m_pSprite.scaleY = -1; m_pSprite.BlendFunc = new CCBlendFunc(CCMacros.CCDefaultSourceBlending, CCMacros.CCDefaultDestinationBlending); // OGLES.GL_ONE, OGLES.GL_ONE_MINUS_SRC_ALPHA); AddChild(m_pSprite); return true; }