You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As my post from smourier/DirectN#34, I modified the function a bit to load all pixel data into a DataGridView.
publicvoidLoadPixelDataIntoDataGrid(){varbmpProps=new D2D1_BITMAP_PROPERTIES1(){bitmapOptions= D2D1_BITMAP_OPTIONS.D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS.D2D1_BITMAP_OPTIONS_CPU_READ,pixelFormat=new D2D1_PIXEL_FORMAT(){alphaMode= D2D1_ALPHA_MODE.D2D1_ALPHA_MODE_PREMULTIPLIED,format= DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM,},dpiX=96.0f,dpiY=96.0f,};varsize= _imageD2D.GetSize().ToD2D_SIZE_U();usingvarbitmap1= _device.CreateBitmap<ID2D1Bitmap1>(size, bmpProps);
bitmap1.CopyFromBitmap(_imageD2D);varmap= bitmap1.Map(D2D1_MAP_OPTIONS.D2D1_MAP_OPTIONS_READ);vardataSize=(int)(size.width * size.height *4);varbytes=newbyte[dataSize];
Marshal.Copy(map.bits, bytes,0, dataSize);
bitmap1.Unmap();// load all pixel data into data grid view
dt.DataSource = bytes.Select((i,index)=>new{ Index = index, Value = i.ToString(),}).ToList();}
The problem
It only returns the first row of the pixel data; the rest values are just 0!
In the demo, I used 4x4 PNG image with alpha pixels, and draw 100X onto the window.
Hi @smourier,
As my post from smourier/DirectN#34, I modified the function a bit to load all pixel data into a
DataGridView
.The problem
It only returns the first row of the pixel data; the rest values are just 0!
In the demo, I used 4x4 PNG image with alpha pixels, and draw 100X onto the window.
Full source code:
WinFormsApp1.zip
The text was updated successfully, but these errors were encountered: