using System.Drawing.Imaging;\r
using System.IO;\r
using System.Diagnostics;\r
-using SlimDX;\r
-using SlimDX.Direct3D9;\r
+using SharpDX;\r
+using SharpDX.Direct3D9;\r
+\r
+using Rectangle = System.Drawing.Rectangle;\r
\r
namespace FDK\r
{\r
/// <param name="pool">テクスチャの管理方法。</param>\r
/// <exception cref="CTextureCreateFailedException">テクスチャの作成に失敗しました。</exception>\r
public CTexture( Device device, int n幅, int n高さ, Format format, Pool pool )\r
- : this( device, n幅, n高さ, format, pool, Usage.None )\r
+ : this( device, n幅, n高さ, format, pool, Usage.None, false )\r
{\r
}\r
\r
- public CTexture( Device device, int n幅, int n高さ, Format format, Pool pool, Usage usage )\r
+ public CTexture( Device device, int n幅, int n高さ, Format format, Pool pool, Usage usage, bool b黒を透過する )\r
: this()\r
{\r
try\r
this.sz画像サイズ = new Size( n幅, n高さ );\r
this.szテクスチャサイズ = this.t指定されたサイズを超えない最適なテクスチャサイズを返す( device, this.sz画像サイズ );\r
this.rc全画像 = new Rectangle( 0, 0, this.sz画像サイズ.Width, this.sz画像サイズ.Height );\r
- \r
- using ( var bitmap = new Bitmap( 1, 1 ) )\r
+ int colorKey = ( b黒を透過する ) ? unchecked((int) 0xFF000000) : 0;\r
+\r
+ using( var bitmap = new Bitmap( 1, 1 ) )\r
{\r
using ( var graphics = Graphics.FromImage( bitmap ) )\r
{\r
pool = poolvar;\r
#endif\r
// 中で更にメモリ読み込みし直していて無駄なので、Streamを使うのは止めたいところ\r
- this.texture = Texture.FromStream( device, stream, n幅, n高さ, 1, usage, format, pool, Filter.Point, Filter.None, 0 );\r
+ this.texture = Texture.FromStream( device, stream, n幅, n高さ, 1, usage, format, pool, Filter.Point, Filter.None, colorKey );\r
}\r
}\r
}\r
}\r
#else\r
IntPtr src_scan0 = (IntPtr) ( (Int64) srcBufData.Scan0 );\r
- destDataRectangle.Data.WriteRange( src_scan0, this.sz画像サイズ.Width * 4 * this.sz画像サイズ.Height );\r
+ //destDataRectangle.Data.WriteRange( src_scan0, this.sz画像サイズ.Width * 4 * this.sz画像サイズ.Height );\r
+ CopyMemory( destDataRectangle.DataPointer.ToPointer(), src_scan0.ToPointer(), this.sz画像サイズ.Width * 4 * this.sz画像サイズ.Height );\r
#endif\r
texture.UnlockRectangle( 0 );\r
bitmap.UnlockBits( srcBufData );\r
float f上V値 = ( (float) rc画像内の描画領域.Top ) / ( (float) this.szテクスチャサイズ.Height );\r
float f下V値 = ( (float) rc画像内の描画領域.Bottom ) / ( (float) this.szテクスチャサイズ.Height );\r
this.color4.Alpha = ( (float) this._透明度 ) / 255f;\r
- int color = this.color4.ToArgb();\r
+ int color = this.color4.ToRgba();\r
\r
if( this.bFlipY )\r
{\r
this.cvTransformedColoredVertexies[ 3 ].Color = color;\r
this.cvTransformedColoredVertexies[ 3 ].TextureCoordinates.X = f右U値;\r
this.cvTransformedColoredVertexies[ 3 ].TextureCoordinates.Y = f下V値;\r
- \r
+\r
device.SetTexture( 0, this.texture );\r
device.VertexFormat = TransformedColoredTexturedVertex.Format;\r
device.DrawUserPrimitives( PrimitiveType.TriangleStrip, 0, 2, this.cvTransformedColoredVertexies );\r
float f上V値 = ( (float) rc画像内の描画領域.Top ) / ( (float) this.szテクスチャサイズ.Height );\r
float f下V値 = ( (float) rc画像内の描画領域.Bottom ) / ( (float) this.szテクスチャサイズ.Height );\r
this.color4.Alpha = ( (float) this._透明度 ) / 255f;\r
- int color = this.color4.ToArgb();\r
+ int color = this.color4.ToRgba();\r
\r
if( this.cvPositionColoredVertexies == null )\r
this.cvPositionColoredVertexies = new PositionColoredTexturedVertex[ 4 ];\r
float f上V値 = ( (float) rc画像内の描画領域.Top ) / ( (float) this.szテクスチャサイズ.Height );\r
float f下V値 = ( (float) rc画像内の描画領域.Bottom ) / ( (float) this.szテクスチャサイズ.Height );\r
this.color4.Alpha = ( (float) this._透明度 ) / 255f;\r
- int color = this.color4.ToArgb();\r
+ int color = this.color4.ToRgba();\r
\r
if( this.cvPositionColoredVertexies == null )\r
this.cvPositionColoredVertexies = new PositionColoredTexturedVertex[ 4 ];\r
if( this.b加算合成 )\r
{\r
device.SetRenderState( RenderState.AlphaBlendEnable, true );\r
- device.SetRenderState( RenderState.SourceBlend, SlimDX.Direct3D9.Blend.SourceAlpha ); // 5\r
- device.SetRenderState( RenderState.DestinationBlend, SlimDX.Direct3D9.Blend.One ); // 2\r
+ device.SetRenderState( RenderState.SourceBlend, Blend.SourceAlpha );\r
+ device.SetRenderState( RenderState.DestinationBlend, Blend.One );\r
}\r
else\r
{\r
device.SetRenderState( RenderState.AlphaBlendEnable, true );\r
- device.SetRenderState( RenderState.SourceBlend, SlimDX.Direct3D9.Blend.SourceAlpha ); // 5\r
- device.SetRenderState( RenderState.DestinationBlend, SlimDX.Direct3D9.Blend.InverseSourceAlpha ); // 6\r
+ device.SetRenderState( RenderState.SourceBlend, Blend.SourceAlpha );\r
+ device.SetRenderState( RenderState.DestinationBlend, Blend.InverseSourceAlpha );\r
}\r
}\r
protected Size t指定されたサイズを超えない最適なテクスチャサイズを返す( Device device, Size sz指定サイズ )\r
// 2012.3.21 さらなる new の省略作戦\r
\r
protected Rectangle rc全画像; // テクスチャ作ったらあとは不変\r
- protected Color4 color4 = new Color4( 1f, 1f, 1f, 1f ); // アルファ以外は不変\r
+ protected Color4 color4 = new Color4( 1f, 1f, 1f, 1f ); // アルファ以外は不変\r
+ //-----------------\r
+ #endregion\r
+\r
+ #region " Win32 API "\r
+ //-----------------\r
+ [System.Runtime.InteropServices.DllImport( "kernel32.dll", SetLastError = true )]\r
+ private static extern unsafe void CopyMemory( void* dst, void* src, int size );\r
//-----------------\r
#endregion\r
}\r