Coder Social home page Coder Social logo

helmare / fastbitmap Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 4.0 3.69 MB

A .NET library that wraps the System.Drawing.Bitmap class for improved pixel read/write performance.

License: MIT License

C# 100.00%
csharp csharp-library dotnet dotnet5 image-processing

fastbitmap's People

Contributors

helmare avatar igneom avatar kemsekov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fastbitmap's Issues

Getting blank color on Linux

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.

Adding Read/Write Methods for Block Pixel Manipulation

Overview

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.

Implementation

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.

Linux: Performing graphics operations have no effect on the color data

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();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.