/// <summary> /// "Assembles" the compiled code, by resolving label references and converting them to index offsets. /// Modifies the code data structure in place, and returns it back to the caller. /// </summary> private static List <Instruction> Assemble(List <Instruction> code) { var positions = new LabelPositions(code); for (int i = 0; i < code.Count; i++) { Instruction inst = code[i]; if (inst.IsJump) { int pos = positions.FindPosition(inst.first); if (pos >= 0) { inst.UpdateJumpDestination(pos); } else { throw new CompilerError($"Can't find jump label {inst.first} during assembly"); } } } return(code); }
protected Image Label_Generic(Image img) { try { System.Drawing.Font font = new System.Drawing.Font("Arial", this.FontSize * this.Scale); using (Graphics g = Graphics.FromImage(img)) { g.DrawImage(img, (float)0, (float)0); g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; StringFormat f = new StringFormat(); f.Alignment = StringAlignment.Near; f.LineAlignment = StringAlignment.Near; int LabelX = 0; int LabelY = 0; LabelPositions LabelPosition = LabelPositions.BOTTOMCENTER; switch (LabelPosition) { case LabelPositions.BOTTOMCENTER: LabelX = img.Width / 2; LabelY = img.Height - (font.Height); f.Alignment = StringAlignment.Center; break; case LabelPositions.BOTTOMLEFT: LabelX = 0; LabelY = img.Height - (font.Height); f.Alignment = StringAlignment.Near; break; case LabelPositions.BOTTOMRIGHT: LabelX = img.Width; LabelY = img.Height - (font.Height); f.Alignment = StringAlignment.Far; break; case LabelPositions.TOPCENTER: LabelX = img.Width / 2; LabelY = 0; f.Alignment = StringAlignment.Center; break; case LabelPositions.TOPLEFT: LabelX = img.Width; LabelY = 0; f.Alignment = StringAlignment.Near; break; case LabelPositions.TOPRIGHT: LabelX = img.Width; LabelY = 0; f.Alignment = StringAlignment.Far; break; }//switch //color a background color box at the bottom of the barcode to hold the string of data g.FillRectangle(new SolidBrush(BackColor), new RectangleF((float)0, (float)LabelY, (float)img.Width, (float)font.Height)); //draw datastring under the barcode image g.DrawString(string.IsNullOrEmpty(label) ? data : label, font, new SolidBrush(ForeColor), new RectangleF((float)0, (float)LabelY, (float)img.Width, (float)font.Height), f); g.Save(); } //using return(img); } //try catch (Exception ex) { throw new Exception("ELABEL_GENERIC-1: " + ex.Message); }//catch }
public Image Encode(TYPE iType, string StringToEncode, Color ForeColor, Color BackColor, int Width, int Height, AlignmentPositions alignment, RotateFlipType rotateFlipType, bool includeLabel, LabelPositions labelPosition) { Encoded_Type = iType; Raw_Data = StringToEncode; this.ForeColor = ForeColor; this.BackColor = BackColor; this.Width = Width; this.Height = Height; this.Alignment = alignment; this.RotateFlipType = rotateFlipType; this.IncludeLabel = includeLabel; this.LabelPosition = labelPosition; return(Encode()); }