예제 #1
0
파일: Sprite.cs 프로젝트: kb10uy/Kb10uy
        /// <summary>
        /// 指定のファイル名の情報を元に、
        /// 9sliceオブジェクトを作成します。
        /// </summary>
        /// <param name="path">9sliceの定義ファイル</param>
        public NineSlice(string path)
        {
            Transparency = 1.0;
            SliceHandles = new int[9];
            SliceRegions = new Region[9];

            Config cf = new Config();
            cf.LoadFile(path);
            var fp = Path.GetDirectoryName(Path.GetFullPath(path));
            GraphicHandle = DX.LoadGraph(Path.Combine(fp, cf["9Slice#File"].StringValue));
            SliceRegions[0] = new Region((double)cf["9Slice#TLSlice"][0], (double)cf["9Slice#TLSlice"][1], (double)cf["9Slice#TLSlice"][2], (double)cf["9Slice#TLSlice"][3]);
            SliceRegions[1] = new Region((double)cf["9Slice#TSlice"][0], (double)cf["9Slice#TSlice"][1], (double)cf["9Slice#TSlice"][2], (double)cf["9Slice#TSlice"][3]);
            SliceRegions[2] = new Region((double)cf["9Slice#TRSlice"][0], (double)cf["9Slice#TRSlice"][1], (double)cf["9Slice#TRSlice"][2], (double)cf["9Slice#TRSlice"][3]);
            SliceRegions[3] = new Region((double)cf["9Slice#MLSlice"][0], (double)cf["9Slice#MLSlice"][1], (double)cf["9Slice#MLSlice"][2], (double)cf["9Slice#MLSlice"][3]);
            SliceRegions[4] = new Region((double)cf["9Slice#MSlice"][0], (double)cf["9Slice#MSlice"][1], (double)cf["9Slice#MSlice"][2], (double)cf["9Slice#MSlice"][3]);
            SliceRegions[5] = new Region((double)cf["9Slice#MRSlice"][0], (double)cf["9Slice#MRSlice"][1], (double)cf["9Slice#MRSlice"][2], (double)cf["9Slice#MRSlice"][3]);
            SliceRegions[6] = new Region((double)cf["9Slice#BLSlice"][0], (double)cf["9Slice#BLSlice"][1], (double)cf["9Slice#BLSlice"][2], (double)cf["9Slice#BLSlice"][3]);
            SliceRegions[7] = new Region((double)cf["9Slice#BSlice"][0], (double)cf["9Slice#BSlice"][1], (double)cf["9Slice#BSlice"][2], (double)cf["9Slice#BSlice"][3]);
            SliceRegions[8] = new Region((double)cf["9Slice#BRSlice"][0], (double)cf["9Slice#BRSlice"][1], (double)cf["9Slice#BRSlice"][2], (double)cf["9Slice#BRSlice"][3]);
            SliceHandles[0] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[0]);
            SliceHandles[1] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[1]);
            SliceHandles[2] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[2]);
            SliceHandles[3] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[3]);
            SliceHandles[4] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[4]);
            SliceHandles[5] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[5]);
            SliceHandles[6] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[6]);
            SliceHandles[7] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[7]);
            SliceHandles[8] = ExtraDxLib.DerivationGraphFromRegion(GraphicHandle, SliceRegions[8]);
        }
예제 #2
0
파일: Util.cs 프로젝트: kb10uy/Kb10uy
 /// <summary>
 /// 元のハンドルの画像から、指定範囲を切り出してあたらしいハンドルを生成します。
 /// </summary>
 /// <param name="org">元ハンドル</param>
 /// <param name="r">切り出す範囲</param>
 /// <returns>新しいハンドル</returns>
 public static int DerivationGraphFromRegion(int org, Region r)
 {
     return DX.DerivationGraph((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height, org);
 }