예제 #1
0
        // Handle Fixed logos (Free Style and cijConnect formats later)
        private void LoadLogos(XmlNode c)
        {
            Bitmap bm = null;

            foreach (XmlNode l in c.ChildNodes)
            {
                if (l is XmlWhitespace || l.Name != "Logo")
                {
                    continue;
                }
                string       layout    = GetXmlAttr(l, "Layout");
                IJPDotMatrix dotMatrix = ParseEnum <IJPDotMatrix>(GetXmlAttr(l, "DotMatrix"));
                int          location  = (int)GetXmlAttrN(l, "Location");
                string       rawData   = GetXmlAttr(l, "RawData");
                if (rawData == string.Empty)
                {
                    string folder       = GetXmlAttr(c, "Folder");
                    string fileName     = GetXmlAttr(l, "FileName");
                    string fullFileName = Path.Combine(folder, fileName + ".bmp");
                    if (File.Exists(fullFileName))
                    {
                        bm = new Bitmap(fullFileName);
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    if (!int.TryParse(GetXmlAttr(l, "Width"), out int width) ||
                        !int.TryParse(GetXmlAttr(l, "Height"), out int height))
                    {
                        GetBitmapSize(dotMatrix, out width, out height);
                    }
                    ulong[] stripes = RawDataToStripes(height, rawData);
                    bm = BuildBitMap(stripes, width, height);
                }
                if (layout == "Fixed")
                {
                    IJPFixedUserPattern upFixed = new IJPFixedUserPattern(location + 1, dotMatrix, bm);
                    ijp.SetFixedUserPattern(upFixed);
                }
                else
                {
                    IJPFreeUserPattern upFree = new IJPFreeUserPattern(location + 1, bm);
                    ijp.SetFreeUserPattern(upFree);
                }
            }
        }
예제 #2
0
        // Get the height and width of a user pattern
        private void GetBitmapSize(IJPDotMatrix dm, out int width, out int height)
        {
            switch (dm)
            {
            case IJPDotMatrix.Size4x5:
                width  = 8;
                height = 5;
                break;

            case IJPDotMatrix.Size5x5:
                width  = 8;
                height = 5;
                break;

            case IJPDotMatrix.Size5x7:
                width  = 8;
                height = 7;
                break;

            case IJPDotMatrix.Size9x7:
                width  = 16;
                height = 7;
                break;

            case IJPDotMatrix.Size7x10:
                width  = -8;
                height = 10;
                break;

            case IJPDotMatrix.Size10x12:
                width  = 16;
                height = 12;
                break;

            case IJPDotMatrix.Size12x16:
                width  = 16;
                height = 16;
                break;

            case IJPDotMatrix.Size18x24:
                width  = 24;
                height = 24;
                break;

            case IJPDotMatrix.Size24x32:
                width  = 32;
                height = 32;
                break;

            case IJPDotMatrix.Size11x11:
                width  = 16;
                height = 11;
                break;

            case IJPDotMatrix.Size5x3_Chimney:
                width  = 5;
                height = 3;
                break;

            case IJPDotMatrix.Size5x5_Chimney:
                width  = 5;
                height = 5;
                break;

            case IJPDotMatrix.Size7x5_Chimney:
                width  = 7;
                height = 5;
                break;

            default:
                width  = -1;
                height = -1;
                break;
            }
        }