GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / HistogramGetRed Method
GdPicture image identifier.
Output parameter. Array of 256 entries containing the red channel histogram data.
Example





In This Topic
HistogramGetRed Method (GdPictureImaging)
In This Topic
Computes the red channel histogram of a GdPicture image.
Syntax
'Declaration
 
Public Function HistogramGetRed( _
   ByVal ImageID As Integer, _
   ByRef Data() As Integer _
) As GdPictureStatus
public GdPictureStatus HistogramGetRed( 
   int ImageID,
   ref int[] Data
)
public function HistogramGetRed( 
    ImageID: Integer;
   var  Data: Integerarray of
): GdPictureStatus; 
public function HistogramGetRed( 
   ImageID : int,
   Data : int[]
) : GdPictureStatus;
public: GdPictureStatus HistogramGetRed( 
   int ImageID,
   ref int[]* Data
) 
public:
GdPictureStatus HistogramGetRed( 
   int ImageID,
   array<int>^% Data
) 

Parameters

ImageID
GdPicture image identifier.
Data
Output parameter. Array of 256 entries containing the red channel histogram data.

Return Value

A member of the GdPictureStatus enumeration.
Example
Getting the red channel histogram of a jpeg image and creating an image representing this histogram.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
 
    // Get the red channel histogram and the image dimensions.
    int[] histo = new int[256];
    gdpictureImaging.HistogramGetRed(imageID, ref histo);
    int count = gdpictureImaging.GetWidth(imageID) * gdpictureImaging.GetHeight(imageID);
 
    gdpictureImaging.ReleaseGdPictureImage(imageID);
 
    // Create an image representing the histogram. 
    // The image has the same width as the histogram and its height is 1000.                
    int histogramID = gdpictureImaging.CreateNewGdPictureImage(256, 1000, 24, Color.White);
    for (int i = 0; i < 256; i++)
    {
        int value = histo[i] * 1000 / count;
        for (int j = 0; j < value; j++)
        {
            gdpictureImaging.PixelSetColor(histogramID, i, j, Color.Red);
        }
    }
 
    gdpictureImaging.SaveAsPNG(histogramID, "histo.png");
    gdpictureImaging.ReleaseGdPictureImage(histogramID);
}
See Also