コード例 #1
0
        }        //end FromFixedHeightStaggered

        public bool FromImageValue(string sFile, int iCharWidth, int iCharHeight, int iRows, int iColumns)
        {
            bool  bGood = false;
            RAnim animNormal;

            RReporting.sLastFile = sFile;
            try {
                animNormal = new RAnim();
                bGood      = Init();
                if (bGood)
                {
                    Console.Error.WriteLine("FromImageValue...");
                    bGood = animNormal.SplitFromImage32(sFile, iCharWidth, iCharHeight, iRows, iColumns);
                    if (animNormal.Frame(0) == null)
                    {
                        Console.Error.WriteLine("SplitFromImage32...FAILED -- Null frame zero upon splitting image in " + String.Format("rfont FromImageValue(sFile={0},iCharWidth={1},iCharHeight={2},iRows={3},iColumns={4})", RReporting.StringMessage(sFile, true), iCharWidth, iCharHeight, iRows, iColumns));
                    }
                    else
                    {
                        Console.Error.WriteLine("SplitFromImage32...OK " + String.Format("rfont FromImageValue(sFile={0},iCharWidth={1},iCharHeight={2},iRows={3},iColumns={4})", RReporting.StringMessage(sFile, true), iCharWidth, iCharHeight, iRows, iColumns));
                    }
                    //animNormal.SaveSeq("etc/test/0.debug-glyph", "png");
                    //RImage.OverlayToBigNoClipRaw(ref riTarget, ref ipAt, ref animNormal.riFrame.byarrData, iCharWidth, iCharHeight, 4);
                    if (bGood)
                    {
                        Normal     = animNormal.CopyAsGray();
                        Bold       = Normal.Copy();
                        Italic     = Normal.Copy();
                        BoldItalic = Normal.Copy();
                        //TODO: finish modifying the Glyph Types -- italics using image manip
                    }
                    else
                    {
                        RReporting.ShowErr("Failed to split image", "splitting image from value", "rfont FromImageValue(" + RReporting.StringMessage(sFile, true) + ",...) {}");
                    }
                    //ShowAsciiTable();
                    //Console.Error.WriteLine("Normal.ToString(true):"+Normal.ToString(true));
                }
                else
                {
                    RReporting.ShowErr("Couldn't initialize font glyph graphics buffer", "initializing font graphics", "RFont FromImageValue");
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "initializing font graphics", "RFont FromImageValue");
            }
            return(bGood);
        }        //end FromImageValue
コード例 #2
0
        }        //end FromImageValue

        public bool FromImage(string sFile, int iCharWidth, int iCharHeight, int iRows, int iColumns)
        {
            bool  bGood = false;
            RAnim animNormal;

            RReporting.sLastFile = sFile;          //TODO: implement this EVERYWHERE
            try {
                animNormal = new RAnim();
                bGood      = Init();
                if (bGood)
                {
                    bGood = animNormal.SplitFromImage32(sFile, iCharWidth, iCharHeight, iRows, iColumns);
                    //animNormal.SaveSeq("etc/test/0.debug-glyph", "png");
                    //RImage.OverlayToBigNoClipRaw(ref riTarget, ref ipAt, ref animNormal.riFrame.byarrData, iCharWidth, iCharHeight, 4);
                    if (bGood)
                    {
                        Normal     = animNormal;
                        Bold       = Normal.Copy();
                        Italic     = Normal.Copy();
                        BoldItalic = Normal.Copy();
                        //TODO: finish modifying the Glyph Types -- italics using image manip
                    }
                    //else RReporting.ShowErr("RFont failed to split image","","RFont FromImage");//already shown by anim
                    //ShowAsciiTable();
                    //Console.Error.WriteLine("Normal.ToString(true):"+Normal.ToString(true));
                }
                else
                {
                    RReporting.ShowErr("Couldn't initialize font glyph graphics buffer", "initializing font graphics", "RFont FromImage");
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "initializing font graphics", "RFont FromImage");
            }
            return(bGood);
        }        //end FromImage
コード例 #3
0
        public bool FromFixedHeightStaggered(string sFile, int iCharHeight)          //this is named FromFixedHeightStaggered while the function it called anim.SplitFromFixedHeightStaggered
        {
            RReporting.sLastFile = sFile + "...";
            bool  bGood      = false;
            RAnim animNormal = null;

            bGood = Init();
            try {
                if (!sFile.EndsWith(".png"))
                {
                    animNormal = new RAnim();
                    RImage riNormal = new RImage();
                    RReporting.sLastFile = sFile + ".png";
                    if (!riNormal.Load(sFile + ".png", 4))                    //assumes 32-bit is needed
                    {
                        RReporting.ShowErr("Cannot load font file", "", "RAnim FromFixedHeightStaggered(\"" + RString.SafeString(sFile) + ".png\")");
                    }
                    RReporting.sParticiple = "splitting normal font image";
                    bGood = animNormal.SplitFromFixedHeightStaggered(riNormal, iCharHeight);
                    if (bGood)
                    {
                        Normal = animNormal;
                        bGood  = Normal != null;
                        if (Normal == null)
                        {
                            RReporting.ShowErr("failed to load normal font though split image returned true", "checking loaded normal font", "rfont_bgra32 FromFixedHeightStaggered");
                        }
                        if (File.Exists(sFile + "-bold.png"))
                        {
                            RReporting.sLastFile = sFile + "-bold.png";
                            if (animarrGlyphType[RFont.GlyphTypeBold] == null)
                            {
                                Bold = new RAnim();
                            }
                            RImage riBold = new RImage();
                            RReporting.sParticiple = "loading bold font image";
                            riBold.Load(sFile + "-bold.png", 4);                         //assumes 32-bit is needed
                            if (!Bold.SplitFromFixedHeightStaggered(riBold, iCharHeight))
                            {
                                RReporting.sParticiple = "falling back to generated bold font";
                                bGood = false;
                                RReporting.ShowErr("Could not split image to bold font frames", "separating bold font frames", "rfont_bgra32 FromFixedHeightStaggered");
                                Bold = animNormal.Copy();
                                //TODO: embolden font manually
                            }
                        }
                        else
                        {
                            RReporting.sParticiple = "getting bold font image from normal";
                            Bold = animNormal.Copy();
                            if (Bold != null)
                            {
                                //TODO: embolden font manually
                            }
                            else
                            {
                                bGood = false;
                                RReporting.ShowErr("Could not copy font frames", "copying font frames to bold font frames", "rfont_bgra32 FromFixedHeightStaggered");
                            }
                        }
                        RReporting.sParticiple = "getting italic font image from normal";
                        Italic = Normal.Copy();
                        if (Italic != null)
                        {
                            //TODO: italicize font manually
                        }
                        else
                        {
                            bGood = false;
                            RReporting.ShowErr("Could not copy font frames", "copying font frames to italic font frames", "rfont_bgra32 FromFixedHeightStaggered");
                        }
                        RReporting.sParticiple = "getting bold italic font image from bold";
                        BoldItalic             = Bold.Copy();
                        if (BoldItalic != null)
                        {
                            //TODO: italicize bold font manually
                        }
                        else
                        {
                            bGood = false;
                            RReporting.ShowErr("Could not copy font frames", "copying font frames to bold italic font frames", "rfont_bgra32 FromFixedHeightStaggered");
                        }
                        CalculateSpacing(GlyphTypeNormal);
                    }
                    else
                    {
                        RReporting.ShowErr("Could not split image to font frames", "separating font frames", "rfont_bgra32 FromFixedHeightStaggered");
                    }
                }
                else
                {
                    bGood = false;
                    RReporting.ShowErr("Font file base name must not end with extension--must have assumed png extension.", "checking raster font file", "rfont_bgra32 FromFixedHeightStaggered");
                }
            }
            catch (Exception exn) {
                bGood = false;
                RReporting.ShowExn(exn, "Splitting Proportional Font Glyphs", "FromFixedHeightStaggered(" + sFile + "," + iCharHeight.ToString() + ")");
            }
            if (this.animarrGlyphType != null)
            {
                for (int i = 0; i < RFont.iGlyphTypes; i++)
                {
                    if (animarrGlyphType[i] == null)
                    {
                        RReporting.ShowErr("Null glyph type " + RFont.GlyphTypeToString(i), "getting glyphs from images", "FromFixedHeightStaggered(sFile=" + RReporting.StringMessage(sFile, true) + ",iCharHeight=" + iCharHeight + ")");
                    }
                    else if (!animarrGlyphType[i].FrameIsCached(0))
                    {
                        RReporting.ShowErr("First glyph is null in glyph type " + RFont.GlyphTypeToString(i), "getting glyphs from images", "FromFixedHeightStaggered(sFile=" + RReporting.StringMessage(sFile, true) + ",iCharHeight=" + iCharHeight + ")");
                    }
                }
            }
            else
            {
                RReporting.ShowErr("Null glyph type array", "getting glyphs from images", "FromFixedHeightStaggered(sFile=" + RReporting.StringMessage(sFile, true) + ",iCharHeight=" + iCharHeight + ")");
            }
            return(bGood);
        }        //end FromFixedHeightStaggered