Reference Guide
GdPicture14 Namespace / GdPictureImaging Class / ConvertTo1Bpp Method / ConvertTo1Bpp(Int32,Byte) Method
GdPicture image identifier.
Value between [1 and 255]. Pixels values less than Threshold will be turned black, values equal to or larger till be turned white. If you do not know what to choose, select 128 which is the medium value.
Example





In This Topic
    ConvertTo1Bpp(Int32,Byte) Method
    In This Topic
    Converts a GdPicture image to a 1-bit BW indexed color image specifying a threshold value. The color table has 2 entries: 1 Black & 1 White.
    Syntax
    'Declaration
     
    
    Public Overloads Function ConvertTo1Bpp( _
       ByVal ImageID As Integer, _
       ByVal Threshold As Byte _
    ) As GdPictureStatus
    public GdPictureStatus ConvertTo1Bpp( 
       int ImageID,
       byte Threshold
    )
    public function ConvertTo1Bpp( 
        ImageID: Integer;
        Threshold: Byte
    ): GdPictureStatus; 
    public function ConvertTo1Bpp( 
       ImageID : int,
       Threshold : byte
    ) : GdPictureStatus;
    public: GdPictureStatus ConvertTo1Bpp( 
       int ImageID,
       byte Threshold
    ) 
    public:
    GdPictureStatus ConvertTo1Bpp( 
       int ImageID,
       byte Threshold
    ) 

    Parameters

    ImageID
    GdPicture image identifier.
    Threshold
    Value between [1 and 255]. Pixels values less than Threshold will be turned black, values equal to or larger till be turned white. If you do not know what to choose, select 128 which is the medium value.

    Return Value

    A member of the GdPictureStatus enumeration.
    Remarks
    The pixel value of colored pixels is computed via the following formula: PixValue = (0.2126F * r + 0.7152F * g + 0.0722F * b)
    Example
    Converts selected image to a 1-bit BW indexed color image, and saves result into a TIF file.
    using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
    {
        // Open an image file. An empty string allows the control to prompt for selecting a file.
        int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
     
        gdpictureImaging.ConvertTo1Bpp(imageID, 128);
        gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionAUTO);
     
        // Release used resources.
        gdpictureImaging.ReleaseGdPictureImage(imageID);
    }
    See Also