BarcodeQRGetSize Method (GdPictureImaging)
In This Topic
Returns the size, in pixels, required to render a QrCode on a Bitmap.
Syntax
'Declaration
Public Function BarcodeQRGetSize( _
ByVal As String, _
ByVal As BarcodeQREncodingMode, _
ByVal As BarcodeQRErrorCorrectionLevel, _
ByRef As Integer, _
ByVal As Integer, _
ByVal As Integer _
) As Integer
public int BarcodeQRGetSize(
string ,
BarcodeQREncodingMode ,
BarcodeQRErrorCorrectionLevel ,
out int ,
int ,
int
)
public function BarcodeQRGetSize(
: String;
: BarcodeQREncodingMode;
: BarcodeQRErrorCorrectionLevel;
Out : Integer;
: Integer;
: Integer
): Integer;
public function BarcodeQRGetSize(
: String,
: BarcodeQREncodingMode,
: BarcodeQRErrorCorrectionLevel,
: int,
: int,
: int
) : int;
public: int BarcodeQRGetSize(
string* ,
BarcodeQREncodingMode ,
BarcodeQRErrorCorrectionLevel ,
[PARAMFLAG::Out] int ,
int ,
int
)
public:
int BarcodeQRGetSize(
String^ ,
BarcodeQREncodingMode ,
BarcodeQRErrorCorrectionLevel ,
[Out] int ,
int ,
int
)
Parameters
- Data
- The data of the barcode to encode.
- EncodingMode
- A member of the BarcodeQREncodingMode enumeration. The encoding mode.
- ErrorCorrectionLevel
- A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
- Version
- Ref. parameter. The version of the QrCode. In the range 0 - 40. Specifies the overall dimensions of the symbol.Use 0 to let the engine decide and return the minimum version required to encode all data.
- QuietZone
- The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode.
QR Code requires a four-module wide margin at all sides of a symbol. Consequently a value superior or equal to 4 is highly suggested.
- ModuleSize
- The size of each module, in pixels. A value superior or equal to 4 is recommended.
Return Value
The size, in pixels, required to render a QrCode.
Example
Rendering a QrCode to a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "Encoding Qr Code";
BarcodeQREncodingMode encodingMode = BarcodeQREncodingMode.BarcodeQREncodingModeUndefined;
BarcodeQRErrorCorrectionLevel errorCorrectionLevel = BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM;
int version = 0;
int moduleSize = 7;
int quietZone = 4;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
// Compute size (in pixels), required to render a Qr Code.
int size = gdpictureImaging.BarcodeQRGetSize(data, encodingMode, errorCorrectionLevel, out version, quietZone, moduleSize);
int imageID = gdpictureImaging.CreateNewGdPictureImage(size, size, 32, Color.White);
gdpictureImaging.BarcodeQRWrite(imageID, data, encodingMode, errorCorrectionLevel, version, quietZone, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "QrCode.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Example
Rendering a QrCode to a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "Encoding Qr Code";
BarcodeQREncodingMode encodingMode = BarcodeQREncodingMode.BarcodeQREncodingModeUndefined;
BarcodeQRErrorCorrectionLevel errorCorrectionLevel = BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM;
int version = 0;
int moduleSize = 7;
int quietZone = 4;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
// Compute size (in pixels), required to render a Qr Code.
int size = gdpictureImaging.BarcodeQRGetSize(data, encodingMode, errorCorrectionLevel, out version, quietZone, moduleSize);
int imageID = gdpictureImaging.CreateNewGdPictureImage(size, size, 32, Color.White);
gdpictureImaging.BarcodeQRWrite(imageID, data, encodingMode, errorCorrectionLevel, version, quietZone, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "QrCode.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also
Reference
GdPictureImaging Class
GdPictureImaging Members
BarcodeQRWrite(Int32,String,BarcodeQREncodingMode,BarcodeQRErrorCorrectionLevel,Int32,Int32,Int32,Int32,Int32,Single,GdPictureColor,GdPictureColor) Method