C# equivilent to Java's java.awt.image.DataBuffer -


here's java code:

import java.awt.image.databuffer;  public class b extends databuffer {   public float[][] a;   public float[] b;    public float[] a()   {     return this.b;   } } 

question plain , simple. c# equivalent java.awt.image.databuffer?

or need 1 level , find equivalent java.awt.image?

tia,

keithc

it sounds trying sort of image manipulation. seem need direct access pixel data bitmap because method calls slow.

.net provides bitmap.lockbits purpose. here’s example how might use this:

var bmp = new bitmap(width, height, pixelformat.format32bppargb); unsafe {     var data = bmp.lockbits(new rectangle(0, 0, width, height), imagelockmode.readwrite, pixelformat.format32bppargb);     (int y = 0; y < height; y++)     {         var b = (byte*) data.scan0 + y * data.stride;         (int x = 0; x < width; x++)         {             var blue = b[4 * x];             var green = b[4 * x + 1];             var red = b[4 * x + 2];             var alpha = b[4 * x + 3];              // ... whatever want these values ...         }     }     bmp.unlockbits(data); } return bmp; 

in order use this, need enable unsafe code in project. in project properties, on “build” tab, enable option allow unsafe code.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -