내가 명확하게 질문을 이해했는지 모르겠지만 SharpDX 샘플에서 'LoadBitmap'과 'CreateTexture2DFromBitmap'의 두 가지 메서드가있는 'TextureLoader'클래스를 발견했습니다. 봐, 당신은 .jpg 파일을, .png를, .BMP에서 BitmapSource는로드이 기능을 사용할 수 있습니다
public static Texture2D CreateTexture2DFromBitmap(Device device, BitmapSource bitmapSource)
{
// Allocate DataStream to receive the WIC image pixels
int stride = bitmapSource.Size.Width * 4;
using (var buffer = new SharpDX.DataStream(bitmapSource.Size.Height * stride, true, true))
{
// Copy the content of the WIC to the buffer
bitmapSource.CopyPixels(stride, buffer);
return new SharpDX.Direct3D11.Texture2D(device, new SharpDX.Direct3D11.Texture2DDescription()
{
Width = bitmapSource.Size.Width,
Height = bitmapSource.Size.Height,
ArraySize = 1,
BindFlags = SharpDX.Direct3D11.BindFlags.ShaderResource,
Usage = SharpDX.Direct3D11.ResourceUsage.Immutable,
CpuAccessFlags = SharpDX.Direct3D11.CpuAccessFlags.None,
Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm,
MipLevels = 1,
OptionFlags = SharpDX.Direct3D11.ResourceOptionFlags.None,
SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
}, new SharpDX.DataRectangle(buffer.DataPointer, stride));
}
}
및 순서에 :
public static BitmapSource LoadBitmap(ImagingFactory2 factory, string filename)
{
var bitmapDecoder = new SharpDX.WIC.BitmapDecoder(
factory,
filename,
SharpDX.WIC.DecodeOptions.CacheOnDemand
);
var result = new SharpDX.WIC.FormatConverter(factory);
result.Initialize(
bitmapDecoder.GetFrame(0),
SharpDX.WIC.PixelFormat.Format32bppPRGBA,
SharpDX.WIC.BitmapDitherType.None,
null,
0.0,
SharpDX.WIC.BitmapPaletteType.Custom);
return result;
}
BitmapSource는에서 Texture2D를 얻으려면 당신이 이것을 사용할 수 있습니다
public static Texture2D LoadFromFile(Device device, ImagingFactory2 factory, string fileName)
{
var bs = LoadBitmap(factory, fileName);
var texture = CreateTexture2DFromBitmap(device, bs);
return texture;
}
을 게시 할 수있다, 그들은 여기 사람들보다 미래의 계획을 더 잘 인식 할 수 있습니다. – ssube
그들은 자신의 포럼이나 메일 링리스트를 가지고 있지 않습니다. =/http://code.google.com/p/sharpdx/ – msedore
바보입니다. 어쩌면 문제를 제기 할 수 있을까요? 나는 꽤 최근의 것들을 보지만, 그들이 반응하는지는 모른다. – ssube