Reputation: 1
I want to show 16bit grayscale satellite image with OpenTK on WPF.
I finally finished making bitmap as WriteableBitmap
. When I save it as png
and open with Qgis, there is no problem with the bitmap but when I set Texture
and watch with OpenTK there is only black window appeared in my WPF.
Is there any problem with this code? If I need to fix it, how should I fix it?
Here is the code of the Texture
:
public static int GenTextureID(WriteableBitmap bmp)
{
int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);
bmp.Lock();
unsafe
{
try
{
GL.TexImage2D(TextureTarget.Texture2D
, 0
, PixelInternalFormat.Luminance
, (int)bmp.Width
, (int)bmp.Height
, 0
, OpenTK.Graphics.OpenGL.PixelFormat.Luminance
, PixelType.UnsignedShort
, bmp.BackBuffer);
}
finally
{
bmp.Unlock();
}
}
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter,(int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
return id;
}
Upvotes: 0
Views: 30