このテクスチャを後で画面にレンダリングできるように、texture2d でスプライトをレンダリングする必要がありますが、同時に、この変更されたテクスチャのピクセルにアクセスする必要があるため、テクスチャにスプライトを追加するとします。スプライトがあった座標で get pixel 関数を呼び出すと、(texture2d とブレンドされた) スプライトに対応する新しいピクセル値が返されます。
3.5以下ではなくxna 4.0を使用しています。
ありがとう。
GDI の Graphics.FromImage(img).DrawImage(... に相当するもの
私はこれを試して失敗しました
public static Texture2D DrawSomething(Texture2D old, int X, int Y, int radius) {
var pp = Res.game.GraphicsDevice.PresentationParameters;
var r = new RenderTarget2D(Res.game.GraphicsDevice, old.Width, old.Height, false, pp.BackBufferFormat, pp.DepthStencilFormat,
pp.MultiSampleCount, RenderTargetUsage.DiscardContents);
Res.game.GraphicsDevice.SetRenderTarget(r);
var s = new SpriteBatch(r.GraphicsDevice);
s.Begin();
s.Draw(old, new Vector2(0, 0), Color.White);
s.Draw(Res.picture, new Rectangle(X - radius / 2, Y - radius / 2, radius, radius), Color.White);
s.End();
Res.game.GraphicsDevice.SetRenderTarget(null);
return r;
}
Res.game は基本的にメインのゲーム フォームへのポインターであり、Res.picture はランダムな texture2d です。