Ich mache derzeit eine 2D-Anwendung mit SharpDX.Direct2D1
.Graustufen 8BPP Bitmap für SharpDX.Direct2D1.Bitmap
Hier ist mein Setup für meinen 2D-Gerätekontext, der korrekt funktioniert.
m_swapchaindesc = New SwapChainDescription()
With m_swapchaindesc
.BufferCount = 2
.ModeDescription =
New ModeDescription(control.Width, control.Height,
New Rational(60, 1), Format.R8G8B8A8_UNorm)
.IsWindowed = True
.OutputHandle = control.Handle
.SampleDescription = New SampleDescription(1, 0)
.SwapEffect = SwapEffect.Discard
.Usage = Usage.RenderTargetOutput
End With
SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport Or DeviceCreationFlags.Debug, m_swapchaindesc, m_device, m_swapChain)
Dim dxgiDevice As SharpDX.DXGI.Device = m_device.QueryInterface(Of SharpDX.DXGI.Device)()
m_2dDevice = New SharpDX.Direct2D1.Device(dxgiDevice)
m_d2dContext = New SharpDX.Direct2D1.DeviceContext(m_2dDevice, SharpDX.Direct2D1.DeviceContextOptions.None)
m_properties = New BitmapProperties(New SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied), 96, 96)
m_backBuffer = m_swapChain.GetBackBuffer(Of Surface)(0)
m_2dTarget = New SharpDX.Direct2D1.Bitmap(m_d2dContext, m_backBuffer, m_properties)
m_d2dContext.Target = m_2dTarget
Meine Frage: Ich möchte 8bpp Bitmap auf einem Graustufen auf meine Device ziehen, was bedeutet, ich brauche es nicht 32bits pro Pixel zu sein, die einen loooot Speicher nimmt. Ich möchte, dass es nur 8 Bits für Speicherzwecke ist. Das Problem, wenn ich das tue, was bedeutet, meine BitmapProperties
einzurichten, gibt es nur eine Format.R8_Unorm
Oder Format.A8_Unorm
, die interessant scheint, da ich denke, sie haben nur 8bpp. Jedoch, wenn ich dieses Format einlege und ich versuche, meine SharpDX.Direct2D1.Bitmap
zu instanziieren, gibt es eine Fehlermeldung zurück, die WRONGPIXELFORMAT sagt.
Ich erkannte, dass nur Format.R8G8B8A8_Unorm
scheint beim Erstellen von Bitmap zu arbeiten, die ich nicht brauche.
Hat jemand von euch mit 8bpp Graustufen-Bitmap auf SharpDX gearbeitet?