문제

Working with this small barcode.dll from Lesinowsky(AKA limilabs barcode plugin). Straight barcode no problem, working as advertised but now I am attempting to rotate barcode image by 90 degrees. And following error occurs:

Cannot implicitly convert type 'int' to 'Lesnikowski.Barcode.RotationType'

Below is exact code which I am using:

    string barCode = barCodeTrans + barCodeSeq + barCodeIndex + rotationindex.ToString();
    Lesnikowski.Barcode.Barcode128 bc = new Lesnikowski.Barcode.Barcode128();
    bc.Rotation = 1; -- error goes away once I remove this line but I need to rotate image
    bc.Number = barCode;
    bc.CustomText = "";
    bc.Height = 28;
    bc.NarrowBarWidth = 2;
    Bitmap bcBitMap = bc.GenerateBitmap();
    string fileName = barCode + ".jpg";
    bcBitMap.Save(outputDir + "/" + fileName, ImageFormat.Jpeg);
    return fileName;

Please advise what is wrong and how to fix this unless that DLL no longer supports rotation of the barcode. Then it would be a shame. Thanks

도움이 되었습니까?

해결책

Below working code. Just make sure that when you passing variables to string barCode -- it is not empty or nulls. Single null in that string formation will ruin your day.

  string barCode = barCodeTrans + barCodeSeq + barCodeIndex + rotationindex.ToString();
  Lesnikowski.Barcode.Barcode128 bc = new Lesnikowski.Barcode.Barcode128();
  bc.Rotation = Lesnikowski.Barcode.RotationType.Degrees90
  bc.Number = barCode;
  bc.CustomText = "";
  bc.Height = 28;
  bc.NarrowBarWidth = 2;
  Bitmap bcBitMap = bc.GenerateBitmap();
  string fileName = barCode + ".jpg";
  bcBitMap.Save(outputDir + "/" + fileName, ImageFormat.Jpeg);
  return fileName;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top