Home > Back-end >  A function to help translation
A function to help translation

Time:10-09

Public int [] GetHisogram Bitmap (img)
{
BitmapData data=https://bbs.csdn.net/topics/img.LockBits (the new System. Drawing. A Rectangle (0, 0, img Width, img. Height), ImageLockMode. ReadWrite, PixelFormat. Format24bppRgb);
Int [] histogram=new int [256].
The unsafe
{
Byte * PTR=(byte *) data. Scan0;
Int remain=data. Stride - data. Width * 3;
for (int i=0; I & lt; The histogram. Length; I++)
The histogram [I]=0;
for (int i=0; I & lt; Data. The Height; I++)
{
For (int j=0; J & lt; Data. The Width; J++)
{
Int mean=PTR PTR [0] + [1] + PTR [2].
Mean/=3;
The histogram [mean] + +;
PTR +=3;
}
PTR +=remain;
}
}
Img. UnlockBits (data);
Img. The Dispose ();
Return the histogram.
}

Thanks to Delphi

CodePudding user response:

Delphi has LockBits?
  • Related