相关疑难解决方法(0)

你如何将HttpPostedFileBase转换为图像?

我正在使用ASP.NET MVC,我有一个上传文件的动作.该文件正在正确上载.但我想要图像的宽度和高度.我想我需要将其转换HttpPostedFileBaseImage第一个然后继续.我怎么做?

如果有另一种更好的方法来获得图像的宽度和高度,请告诉我.

image httppostedfilebase asp.net-mvc-file-upload

46
推荐指数
2
解决办法
3万
查看次数

从 PixelFormat 获取像素长度

如何从PixelFormat枚举中获取像素长度(以字节为单位)?我想使用本机方法处理图像像素,但是如果我不知道像素的偏移量,我如何遍历图像。

代码:

let formRgbCube (image : Bitmap) =
    let width = image.Width
    let height = image.Height
    let bitmapData = image.LockBits(Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, image.PixelFormat)
    let ptr = NativePtr.ofNativeInt<byte>(bitmapData.Scan0)
    let stride = bitmapData.Stride

    let rgbCube = Array3D.zeroCreate width height 3
    for i = 0 to width - 1 do
        for j = 0 to height - 1 do
            for k = 0 to 2 do
                rgbCube.[i, j, k] <- NativePtr.read<byte>(NativePtr.add ptr (stride * j + i * 3(*an …
Run Code Online (Sandbox Code Playgroud)

.net c# f# image-processing

5
推荐指数
1
解决办法
2488
查看次数

如何在C#中将位图图像转换为IntPtr?

我从我看到的一个例子中做到了这一点,它从未抛出任何错误,但图像显示为灰色.

有一个更好的方法吗?

private unsafe void menuItem7_Click(object sender, EventArgs e)
    {
        var settings = Utility.GatherLocalSettings();

        openFileDialog1.InitialDirectory = settings.SavePath;
        openFileDialog1.Filter = "Scan Files (*.jpg)|*.jpg";
        openFileDialog1.FilterIndex = 1;
        openFileDialog1.RestoreDirectory = true;

        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            byte[] openFile = File.ReadAllBytes(openFileDialog1.FileName);
            fixed (byte* p = openFile)
            {
                IntPtr img = (IntPtr)p;

                frmContainer newScan = new frmContainer(img);
                newScan.MdiParent = this;
                newScan.Text = Path.GetFileName(openFileDialog1.FileName) + " [Saved]";
                newScan.Show();
            }
        }

    }
Run Code Online (Sandbox Code Playgroud)

PS:我检查了csproj以允许构建中的不安全代码.

c# bitmap intptr

3
推荐指数
1
解决办法
1万
查看次数

如何将.NET位图和OpenCV图像指向同一块内存?

如何将.NET位图和OpenCV图像指向同一块内存?我知道我可以从一个复制到另一个,但我更希望他们只指向相同的像素.

使用Emgu的解决方案的奖励积分.

.net opencv bitmap emgucv

1
推荐指数
1
解决办法
3528
查看次数