private void DrawInternal(DeviceContext pContext, BitmapResource pBitmap, Vector2 pPosition, Size pSize) { _effects[0].SetInput(0, pBitmap.DirectXBitmap, false); float widthFactor; float heightFactor; if (_useTiledScaling) { widthFactor = Game.ActiveCamera.Zoom; heightFactor = Game.ActiveCamera.Zoom; } else { widthFactor = pSize.Width / pBitmap.Width; heightFactor = pSize.Height / pBitmap.Height; } var scale = new SharpDX.Direct2D1.Effect(_context, Scale); scale.SetValue(0, new RawVector2(widthFactor, heightFactor)); scale.SetInput(0, _effects[_effects.Count - 1].Output, false); if (pBitmap.Source.HasValue) { var r = pBitmap.Source.Value; var source = new RawRectangleF(r.Left, r.Top, r.Left + pSize.Width, r.Top + pSize.Height); pContext.DrawImage(scale.Output, pPosition, source, InterpolationMode.Linear, CompositeMode.SourceOver); } else { pContext.DrawImage(_effects[_effects.Count - 1].Output, pPosition); } }
internal void Render(DeviceContext context) { if (BaseImage == null) { CropEffect.SetInput(0, ParentAtlas.ImageResource.Image, true); CropEffect.SetValue((int)CropProperties.Rectangle, Rect); context.DrawImage(CropEffect); CropEffect.SetInput(0, null, true); return; } context.DrawImage(BaseImage.Image); }
public static void DrawImage(this DeviceContext context, ID2DImage image, float destX, float destY, float srcX, float srcY, float srcWidth, float srcHeight, InterpolationMode interpolationMode, CompositeMode compositeMode) { var dstOffset = new RawVector2(destX, destY); var srcRect = new RawRectangleF(srcX, srcY, srcX + srcWidth, srcY + srcHeight); context.DrawImage(image.NativeImage, dstOffset, srcRect, interpolationMode, compositeMode); }
// 進行と描画 public void 進行描画する(DeviceContext dc, bool 黒幕付き = false, Vector4?表示領域 = null, LayerParameters1?layerParameters1 = null) { #region " 初めての進行描画 " //---------------- if (this._初めての進行描画) { // 背景画像と黒幕付き背景画像のそれぞれに対して、 // エフェクトチェーン(拡大 → ぼかし → クリッピング)を作成する。 if (null != this._背景画像) { this._拡大エフェクト.SetInput(0, this._背景画像.Bitmap, true); this._ガウスぼかしエフェクト.SetInputEffect(0, this._拡大エフェクト); this._クリッピングエフェクト.SetInputEffect(0, this._ガウスぼかしエフェクト); } if (null != this._背景黒幕付き画像) { this._拡大エフェクト黒幕付き用.SetInput(0, this._背景黒幕付き画像.Bitmap, true); this._ガウスぼかしエフェクト黒幕付き用.SetInputEffect(0, this._拡大エフェクト黒幕付き用); this._クリッピングエフェクト黒幕付き用.SetInputEffect(0, this._ガウスぼかしエフェクト黒幕付き用); } this._初めての進行描画 = false; } //---------------- #endregion double 割合 = this._ぼかしと縮小割合?.Value ?? 0.0; if (黒幕付き) { #region " (A) 黒幕付き背景画像を描画する。" //---------------- this._拡大エフェクト黒幕付き用.ScaleAmount = new Vector2((float)(1f + (1.0 - 割合) * 0.04)); // 1.04 ~ 1 this._ガウスぼかしエフェクト黒幕付き用.StandardDeviation = (float)(割合 * 10.0); // 0~10 this._クリッピングエフェクト黒幕付き用.Rectangle = (null != 表示領域) ? ((Vector4)表示領域) : new Vector4(0f, 0f, this._背景黒幕付き画像.サイズ.Width, this._背景黒幕付き画像.サイズ.Height); DXResources.Instance.D2DBatchDraw(dc, () => { dc.PrimitiveBlend = PrimitiveBlend.SourceOver; if (layerParameters1.HasValue) { // (A-a) レイヤーパラメータの指定あり using (var layer = new Layer(dc)) { dc.PushLayer(layerParameters1.Value, layer); dc.DrawImage(this._クリッピングエフェクト黒幕付き用); dc.PopLayer(); } } else { // (A-b) レイヤーパラメータの指定なし dc.DrawImage(this._クリッピングエフェクト黒幕付き用); } }); //---------------- #endregion } else { #region " (B) 背景画像を描画する。" //---------------- this._拡大エフェクト.ScaleAmount = new Vector2((float)(1f + (1.0 - 割合) * 0.04)); // 1.04 ~ 1 this._ガウスぼかしエフェクト.StandardDeviation = (float)(割合 * 10.0); // 0~10 this._クリッピングエフェクト.Rectangle = (null != 表示領域) ? ((Vector4)表示領域) : new Vector4(0f, 0f, this._背景画像.サイズ.Width, this._背景画像.サイズ.Height); DXResources.Instance.D2DBatchDraw(dc, () => { dc.PrimitiveBlend = PrimitiveBlend.SourceOver; if (layerParameters1.HasValue) { // (B-a) レイヤーパラメータの指定あり using (var layer = new Layer(dc)) { dc.PushLayer(layerParameters1.Value, layer); dc.DrawImage(this._クリッピングエフェクト); dc.PopLayer(); } } else { // (B-b) レイヤーパラメータの指定なし dc.DrawImage(this._クリッピングエフェクト); } }); //---------------- #endregion } }
public static void DrawImage(this DeviceContext context, ID2DImage image, float destX, float destY) { context.DrawImage(image, destX, destY, InterpolationMode.Linear, CompositeMode.SourceOver); }
public static void DrawImage(this DeviceContext context, D2DEffect effect, float destX, float destY, InterpolationMode interpolationMode, CompositeMode compositeMode) { var dstOffset = new RawVector2(destX, destY); context.DrawImage(effect.NativeEffect, dstOffset, interpolationMode, compositeMode); }
public static void DrawImage(this DeviceContext context, D2DEffect effect, float destX, float destY) { var dstOffset = new RawVector2(destX, destY); context.DrawImage(effect.NativeEffect, dstOffset); }
public static void DrawImage(this DeviceContext context, D2DEffect effect, InterpolationMode interpolationMode, CompositeMode compositeMode) { context.DrawImage(effect.NativeEffect, interpolationMode, compositeMode); }
public static void DrawImage(this DeviceContext context, D2DEffect effect) { context.DrawImage(effect.NativeEffect); }
public static void DrawImage(this DeviceContext context, ID2DImage image, float destX, float destY, InterpolationMode interpolationMode, CompositeMode compositeMode) { var dstOffset = new RawVector2(destX, destY); context.DrawImage(image.NativeImage, dstOffset, null, interpolationMode, compositeMode); }