将颜色数组转换为WPF C的可读图像#
我有以下问题:我想写一个基本的程序,渲染代码创建的图像。但我在显示图像时遇到问题。 我将图像保存在一个三维数组中,如下所示:Image[x-Pos,y-Pos,RGB值]。现在我的问题是,如何将其转换为可以在GUI上的WPF图像对象中显示的对象?将颜色数组转换为WPF C的可读图像#,wpf,image,Wpf,Image,我有以下问题:我想写一个基本的程序,渲染代码创建的图像。但我在显示图像时遇到问题。 我将图像保存在一个三维数组中,如下所示:Image[x-Pos,y-Pos,RGB值]。现在我的问题是,如何将其转换为可以在GUI上的WPF图像对象中显示的对象? 您的Tifferan将数据转换为字节数组,该数组包含从左上角到右下角连续的所有像素。然后根据以下数据创建位图源: int width = ... int height = ... var format = PixelFormats.Rgb24; var
您的Tifferan将数据转换为字节数组,该数组包含从左上角到右下角连续的所有像素。然后根据以下数据创建位图源:
int width = ...
int height = ...
var format = PixelFormats.Rgb24;
var stride = (width * format.BitsPerPixel + 7) / 8;
var pixels = new byte[stride * height];
// copy data to pixels array
...
var bitmap = BitmapSource.Create(
width, height, 96, 96, format, null, pixels, stride);
也就是说,将图像数据存储在三维数组中似乎没有意义。我可以理解二维数组,其中维度是像素的x和y坐标,数组值是像素(例如RGB)值。将数据转换为字节数组,该数组包含从左上角到右下角连续的所有像素。然后根据以下数据创建位图源:
int width = ...
int height = ...
var format = PixelFormats.Rgb24;
var stride = (width * format.BitsPerPixel + 7) / 8;
var pixels = new byte[stride * height];
// copy data to pixels array
...
var bitmap = BitmapSource.Create(
width, height, 96, 96, format, null, pixels, stride);
也就是说,将图像数据存储在三维数组中似乎没有意义。我可以理解二维数组,其中维度是像素的x和y坐标,数组值是像素(例如RGB)值。将数据转换为字节数组,该数组包含从左上角到右下角连续的所有像素。然后根据以下数据创建位图源:
int width = ...
int height = ...
var format = PixelFormats.Rgb24;
var stride = (width * format.BitsPerPixel + 7) / 8;
var pixels = new byte[stride * height];
// copy data to pixels array
...
var bitmap = BitmapSource.Create(
width, height, 96, 96, format, null, pixels, stride);
也就是说,将图像数据存储在三维数组中似乎没有意义。我可以理解二维数组,其中维度是像素的x和y坐标,数组值是像素(例如RGB)值。将数据转换为字节数组,该数组包含从左上角到右下角连续的所有像素。然后根据以下数据创建位图源:
int width = ...
int height = ...
var format = PixelFormats.Rgb24;
var stride = (width * format.BitsPerPixel + 7) / 8;
var pixels = new byte[stride * height];
// copy data to pixels array
...
var bitmap = BitmapSource.Create(
width, height, 96, 96, format, null, pixels, stride);
也就是说,将图像数据存储在三维数组中似乎没有意义。我可以理解二维数组,其中的维度是像素的x和y坐标,数组值是像素(例如RGB)值。您可以玩
WriteableBitmap
或直接在DrawingGroup
或DrawingVisual
Thx上绘制图像内容,我将研究您可以玩WriteableBitmap
或直接在DrawingGroup
上绘制图像内容,或DrawingVisual
Thx我将研究一下你可以玩WriteableBitmap
或者直接在DrawingGroup
或者DrawingVisual
Thx上直接绘制图像内容,我将研究一下你可以玩WriteableBitmap
或者直接绘制图像内容直接在DrawingGroup
或DrawingVisual
Thx上,我将对此进行研究