helmare / fastbitmap Goto Github PK
View Code? Open in Web Editor NEWA .NET library that wraps the System.Drawing.Bitmap class for improved pixel read/write performance.
License: MIT License
A .NET library that wraps the System.Drawing.Bitmap class for improved pixel read/write performance.
License: MIT License
The get and set methods seem to work normally on windows, but on linux, the get method always returns a blank color.
As far as my understanding of the code goes, you seem to be initializing the BaseBitmap with a pointer to the Data array, so it can be a direct access to the pixels on the Bitmap, and that seems to be causing an issue with the Graphics.DrawImage method, which seems to not be drawing at all on the BaseBitmap when the code is ran on linux.
I'm using Ubuntu 20.04, and verified that If you just call DrawImage on a regular bitmap, it works as expected with no issues, but when creating a FastBitmap object, passing a Bitmap object as argument, the Data array is entirely comprised of zeros. If you use any of the set methods, it works just fine, which leads to DrawImage being the culprit.
I'm not sure if it's possible, but instead of getting the pointer of the Data array, and embedding in the BaseBitmap, do the opposite, get the Data array to point to the BaseBitmap internal data, that could be a solution, and also would remove the need to draw the image parameter on the BaseBitmap. But i'm not knowledgeable enough to know if that's a possibility. But I will try some other possible solutions in the mean time, while I wait for your answer.
Read/Write methods should be added to this library to allow faster operations when working with raw data. This was first proposed on pull request #5, but I believe this will take quite a bit of time and code to implement properly. I've created a new branch called readwrite to expedite pull requests into that branch.
I've done some experiments and concluded that the Read
and Write
methods should act as they do in Stream
's, but also include a position
argument to dictate where in the bitmap the pixel data should be read or written.
Both Read
and Write
methods should return an int
to communicate how much of the buffer was used, because both read and write can't change the size of the bitmap or buffer.
Any contributions and discussion are welcome, and I hope this will improve the usability of this library greatly.
The code below results in no change to FastBitmap.Data
when it is ran on Linux (Ubuntu 20.04).
using (Graphics g = Graphics.FromImage(FastBmp.BaseBitmap))
using (SolidBrush brush = new SolidBrush(Color.Red))
{
g.FillRectangle(brush, 0, 0, FastBmp.Width, FastBmp.Height);
g.Flush();
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.