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
It shows a single element because mapPixels is a pointer and it shows the element it is pointing to. This does not mean there is only one element inside it.
You can see this by looping through the colors. Note there is a large number of colors in screendata.
unsafe
{varimg= Raylib.GetScreenData();varimg2= Raylib.GetImageData(img);Color*mapPixels=(Color*)img2.ToPointer();for(inti=0;i< img.width * img.height;i+=1){Colorcolor= mapPixels[i];// Use color here}
You could also use the newer Span which may be more suitable for your needs.
unsafe
{varimg= Raylib.GetScreenData();varimg2= Raylib.GetImageData(img);Span<Color>colors=newSpan<Color>(img2.ToPointer(), img.width * img.height);foreach(var color in colors){// Use color here}}
Hi
I've been attempting to get a
Color[]
from the screen but not sure how to get the array of pixels from theToPointer
, just returns a singleColor
?The text was updated successfully, but these errors were encountered: