01-14-2008, 15:57
|
RobbAllen
Joined on 01-14-2008
Posts 8
|
The most simple of .Net Applicaitons
|
 
 
|
|
|
I am tasked with rendering GS1 Databar (RSS14 Stacked) images. All I'm trying to do is get a picturebox to get filled with the barcode.
The set up is simple. A Windows form with a 300x150 picture box, a text box and a button. In the onclick event, I do the following
private void button1_Click(object sender, EventArgs e)
{
Bitmap b = new Bitmap(300, 150);
pictureBox1.Image = b;
RasterImage ri = new RasterImage(pictureBox1.Image);
Barcode1d _barcodeWrite1d = new Barcode1d();
_barcodeWrite1d.Direction = BarcodeDirectionFlags.Horizontal;
_barcodeWrite1d.OutShowText = true;
_barcodeWrite1d.ErrorCheck = false;
_barcodeWrite1d.StandardFlags = Barcode1dStandardFlags.Barcode1dMsiModulo10 |
Barcode1dStandardFlags.Barcode1dFast |
Barcode1dStandardFlags.Barcode1dCode11C;
BarcodeEngine _barcodeEngine = new BarcodeEngine();
BarcodeData _barcodeWriteData = new BarcodeData();
_barcodeWriteData.SearchType = BarcodeSearchTypeFlags.Barcode1dEan13;
_barcodeWriteData.Unit = BarcodeUnit.ScanlinesPerPixels;
_barcodeWriteData.Location = new Rectangle(0, 0, 300, 150);
BarcodeColor _barcodeWriteColor = new BarcodeColor();
_barcodeWriteColor.BarColor = Color.FromArgb(0, 0, 0);
_barcodeWriteColor.SpaceColor = Color.FromArgb(255, 255, 255);
BarcodeWriteFlags _barcodeWriteFlags = BarcodeWriteFlags.None;
BarcodeWritePdf _barcodeWritePDF = new BarcodeWritePdf();
BarcodeWriteQr _barcodeWriteQR = new BarcodeWriteQr();
BarcodeWriteDatamatrix _barcodeWriteDM = new BarcodeWriteDatamatrix();
_barcodeWriteDM.XModule = 30;
BarcodeData barcodeData = new BarcodeData();
string[] data = new string[1];
data[0] = textBox1.Text;
byte[] convData = BarcodeData.ConvertFromStringArray(data);
barcodeData.Data = new byte[convData.Length - 1];
System.Array.Copy(convData, barcodeData.Data, barcodeData.Data.Length);
_barcodeWriteData.Data = barcodeData.Data;
_barcodeEngine.Write(ri,
_barcodeWriteData,
_barcodeWriteColor,
_barcodeWriteFlags,
_barcodeWrite1d,
_barcodeWritePDF,
_barcodeWriteDM,
_barcodeWriteQR,
Rectangle.Empty);
}
When I run it and click on the button, it breaks at the Write function with "Operation failed". No inner exceptions or anything.
I'm just trying to use the code I see in the example to try to get this running, so excuse any superfluous code in there.
Thanks.
|
|
|
|
|
Report
|
|
|
|