Giter Site home page Giter Site logo

colorzxing.net's People

Contributors

hainanzhao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

colorzxing.net's Issues

Memory leak in GetRGBByteArrayFromBitmap

Hi,

I just want to say great project.

By using it, I found out that you forgot to unblock the bitmap in GetRGBByteArrayFromBitmap.

In case you write a routine that needs to decode many QR codes then we get a memory leak problem that is not cleaned. If you ad at the end of your method: bitmap.UnlockBits(bmd); then the problem is solved.

Best regards

Andre

private static void GetRGBByteArrayFromBitmap(Bitmap bitmap, byte[] blue, byte[] green, byte[] red)
{
var bmd = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
var width = bitmap.Width;
var height = bitmap.Height;
var stride = bmd.Stride;
var scan0 = bmd.Scan0;

        for (int y = 0; y < height; y++)
        {
            var row = IntPtr.Add(scan0, (y * stride));
            for (int x = 0; x < width; x++)
            {
                var imgIndex = IntPtr.Add(row, x * Constants.PixelSize);
                var index = (y * width + x) * Constants.Gray8PixelSize;

                blue[index] = Marshal.ReadByte(IntPtr.Add(imgIndex, 0));
                green[index] = Marshal.ReadByte(IntPtr.Add(imgIndex, 1));
                red[index] = Marshal.ReadByte(IntPtr.Add(imgIndex, 2));
            }
        };

        bitmap.UnlockBits(bmd);
        
    }

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.