コード例 #1
0
        protected override bool LoadNewFile(string path)
        {
            Texture2D tex = new Texture2D(0, 0, TextureFormat.RGBA32, false);

            if (Srf.ValidateSrf(path))
            {
                tex.LoadImage(Srf.ToJpg(File.ReadAllBytes(path)));
            }
            else if (Srf.ValidateJpg(path))
            {
                tex.LoadImage(File.ReadAllBytes(path));
            }
            else
            {
                return(false);
            }

            tex.filterMode      = FilterMode.Point;
            tex.name            = Path.GetFileName(path);
            Global.inst.srfName = path;
            Global.inst.srf     = tex;
            Global.inst.textAgent.Update(textRequest, Path.GetFileName(path));

            return(true);
        }
コード例 #2
0
    static void SrfTest()
    {
        if (!Srf.ValidateJpg("./Test/res/x.jpg"))
        {
            throw new FileLoadException("Input is not a jpg file.");
        }
        if (!Srf.ValidateSrf("./Test/res/x.srf"))
        {
            throw new FileLoadException("Input is not a srf file.");
        }
        var xjpg = File.ReadAllBytes("./Test/res/x.jpg");
        var xsrf = File.ReadAllBytes("./Test/res/x.srf");

        File.WriteAllBytes("./Test/res/M00.srf", Srf.ToSrf(xjpg));
        File.WriteAllBytes("./Test/res/M00.jpg", Srf.ToJpg(xsrf));

        Bitmap bitmap = (Bitmap)Bitmap.FromFile("./Test/res/M00.jpg");

        bitmap.Save("./Test/res/jpgCompatiabiliyTest.jpg");
    }