Comments (2)
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
{
var img = Raylib.GetScreenData();
var img2 = Raylib.GetImageData(img);
Color* mapPixels = (Color*)img2.ToPointer();
for (int i = 0; i < img.width * img.height; i += 1)
{
Color color = mapPixels[i];
// Use color here
}
You could also use the newer Span which may be more suitable for your needs.
unsafe
{
var img = Raylib.GetScreenData();
var img2 = Raylib.GetImageData(img);
Span<Color> colors = new Span<Color>(img2.ToPointer(), img.width * img.height);
foreach (var color in colors)
{
// Use color here
}
}
from raylib-cs.
Thanks. I wasn't aware of Span or the Color*
asterix reference in C#. That should've rang bells from using C.
Note there is a large number of colors in screendata.
Yes, I do have a small display though which may help it get through the work! :)
from raylib-cs.
Related Issues (20)
- In the `InputGamepad` demo the gamepad image is never displayed. There are multiple contributing factors and related problems. HOT 4
- DllImport fails find raylib.dll on Windows HOT 7
- Some constants are missing from rlgl HOT 2
- Make fields in 'RenderBatch' struct public HOT 1
- MeasureText always returns 0 HOT 1
- Missing Vector3 definition? HOT 2
- IsMaterialReady doesn't contain Material argument HOT 1
- CameraPitch and CameraYaw don't allow passing a Camera3D as ref HOT 5
- [Feature Request] Safe pathway to LoadFontFromMemory HOT 4
- Update to Raylib-5.0.0 HOT 1
- Invalid signature for "GenImageText"
- Add a managed version as a separated package HOT 1
- Suggestion: pin GitHub Action to most recent LTS version of Ubuntu HOT 2
- raylib drawline & alpha HOT 2
- [BUG] `DllImport` makes problems on some pcs HOT 1
- Building for WebAssembly
- [Feature] Repackage Raylib-cs. HOT 2
- feature request - LoadFontEx / LoadFont HOT 1
- Hide console HOT 2
- RayGui support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raylib-cs.