第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

C#RGB [,]到圖片框

C#RGB [,]到圖片框

C#
紫衣仙女 2021-05-05 17:42:22
我有一個(2448 * 2048)5Mpixel圖像數(shù)據(jù)的數(shù)據(jù),但該圖片框只有(816 * 683)約500,000像素,因此我降低了像素,只需要一個黑白圖像,所以我使用了G值創(chuàng)建圖像,但是我輸出的圖像如下圖所示。我的錯誤是哪一部分? public int[,] lowered(int[,] greenar)    {        int[,] Sy = new int[816, 683];        int x = 0;        int y = 0;        for (int i = 1; i < 2448; i += 3)        {            for (int j = 1; j < 2048; j += 3)            {                Sy[x, y] = greenar[i, j];                y++;            }            y = 0;            x++;        }        return Sy;    }static Bitmap Create(int[,] R, int[,] G, int[,] B)    {        int iWidth = G.GetLength(1);        int iHeight = G.GetLength(0);        Bitmap Result = new Bitmap(iWidth, iHeight,        System.Drawing.Imaging.PixelFormat.Format24bppRgb);        Rectangle rect = new Rectangle(0, 0, iWidth, iHeight);        System.Drawing.Imaging.BitmapData bmpData = Result.LockBits(rect,        System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);        IntPtr iPtr = bmpData.Scan0;        int iStride = bmpData.Stride;        int iBytes = iWidth * iHeight * 3;        byte[] PixelValues = new byte[iBytes];        int iPoint = 0;        for (int i = 0; i < iHeight; i++)        {            for (int j = 0; j < iWidth; j++)            {                int iG = G[i, j];                int iB = G[i, j];                int iR = G[i, j];                PixelValues[iPoint] = Convert.ToByte(iB);                PixelValues[iPoint + 1] = Convert.ToByte(iG);                PixelValues[iPoint + 2] = Convert.ToByte(iR);                iPoint += 3;            }        }        System.Runtime.InteropServices.Marshal.Copy(PixelValues, 0, iPtr, iBytes);        Result.UnlockBits(bmpData);        return Result;    }
查看完整描述

2 回答

?
慕運維8079593

TA貢獻1876條經(jīng)驗 獲得超5個贊

您無需對圖像進行降采樣,就可以通過這種方式進行。將picturebox屬性BackgroundImageLayout設(shè)置為zoom或Stretch并將其分配為:


picturebox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;

picturebox.BackgroundImage = bitmap;

System.Windows.Forms.ImageLayout.Zoom將自動將位圖調(diào)整為圖片框的大小。


查看完整回答
反對 回復 2021-05-16
  • 2 回答
  • 0 關(guān)注
  • 196 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號