Example #1
0
        public static DDPicture Mirror(string file)
        {
            return(new DDPicture(
                       () =>
            {
                int siHandle = DDPictureLoaderUtils.FileData2SoftImage(DDPictureLoaderUtils.File2FileData(file));
                int w;
                int h;

                DDPictureLoaderUtils.GetSoftImageSize(siHandle, out w, out h);

                {
                    int h2 = DDPictureLoaderUtils.CreateSoftImage(w * 2, h);

                    for (int x = 0; x < w; x++)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            DDPictureLoaderUtils.Dot dot = DDPictureLoaderUtils.GetSoftImageDot(siHandle, x, y);

                            DDPictureLoaderUtils.SetSoftImageDot(h2, x, y, dot);
                            DDPictureLoaderUtils.SetSoftImageDot(h2, w * 2 - 1 - x, y, dot);
                        }
                    }
                    DDPictureLoaderUtils.ReleaseSoftImage(siHandle);
                    siHandle = h2;
                }

                return DDPictureLoaderUtils.GraphicHandle2Info(DDPictureLoaderUtils.SoftImage2GraphicHandle(siHandle));
            },
                       DDPictureLoaderUtils.ReleaseInfo,
                       DDPictureUtils.Add
                       ));
        }
Example #2
0
        /// <summary>
        /// 左上隅のピクセルの色を透明色として処理する。
        /// 拡大する。
        /// </summary>
        /// <param name="file">画像ファイル</param>
        /// <param name="expNum">拡大率</param>
        /// <returns>画像</returns>
        public static DDPicture BgTransExpand(string file, int expNum)
        {
            return(new DDPicture(
                       () =>
            {
                int siHandle = DDPictureLoaderUtils.FileData2SoftImage(DDPictureLoaderUtils.File2FileData(file));
                int w;
                int h;

                DDPictureLoaderUtils.GetSoftImageSize(siHandle, out w, out h);

                DDPictureLoaderUtils.Dot targetDot = DDPictureLoaderUtils.GetSoftImageDot(siHandle, 0, 0);                         // 左上隅のピクセル

                {
                    int new_w = w * expNum;
                    int new_h = h * expNum;
                    int new_si_h = DDPictureLoaderUtils.CreateSoftImage(new_w, new_h);

                    for (int x = 0; x < w; x++)
                    {
                        for (int y = 0; y < h; y++)
                        {
                            DDPictureLoaderUtils.Dot dot = DDPictureLoaderUtils.GetSoftImageDot(siHandle, x, y);

                            if (
                                targetDot.R == dot.R &&
                                targetDot.G == dot.G &&
                                targetDot.B == dot.B
                                )
                            {
                                dot.A = 0;
                            }

                            for (int sx = 0; sx < expNum; sx++)
                            {
                                for (int sy = 0; sy < expNum; sy++)
                                {
                                    DDPictureLoaderUtils.SetSoftImageDot(new_si_h, x * expNum + sx, y * expNum + sy, dot);
                                }
                            }
                        }
                    }
                    DDPictureLoaderUtils.ReleaseSoftImage(siHandle);
                    siHandle = new_si_h;
                }

                return DDPictureLoaderUtils.GraphicHandle2Info(DDPictureLoaderUtils.SoftImage2GraphicHandle(siHandle));
            },
                       DDPictureLoaderUtils.ReleaseInfo,
                       DDPictureUtils.Add
                       ));
        }
Example #3
0
        public static DDPicture Mirror(string file, I4Rect derRect)
        {
            return(new DDPicture(
                       () =>
            {
                int siHandle = DDPictureLoaderUtils.FileData2SoftImage(DDPictureLoaderUtils.File2FileData(file));
                //int w;
                //int h;

                //DDPictureLoaderUtils.GetSoftImageSize(siHandle, out w, out h);

                {
                    int h2 = DDPictureLoaderUtils.CreateSoftImage(derRect.W * 2, derRect.H);

                    for (int x = 0; x < derRect.W; x++)
                    {
                        for (int y = 0; y < derRect.H; y++)
                        {
                            DDPictureLoaderUtils.Dot dot = DDPictureLoaderUtils.GetSoftImageDot(
                                siHandle,
                                derRect.L + x,
                                derRect.T + y
                                );

                            DDPictureLoaderUtils.SetSoftImageDot(
                                h2,
                                x,
                                y,
                                dot
                                );
                            DDPictureLoaderUtils.SetSoftImageDot(
                                h2,
                                derRect.W * 2 - 1 - x,
                                y,
                                dot
                                );
                        }
                    }
                    DDPictureLoaderUtils.ReleaseSoftImage(siHandle);
                    siHandle = h2;
                }

                return DDPictureLoaderUtils.GraphicHandle2Info(DDPictureLoaderUtils.SoftImage2GraphicHandle(siHandle));
            },
                       DDPictureLoaderUtils.ReleaseInfo,
                       DDPictureUtils.Add
                       ));
        }
Example #4
0
        public static DDPicture Reduct(string file, int denom)
        {
            return(new DDPicture(
                       () =>
            {
                int siHandle = DDPictureLoaderUtils.FileData2SoftImage(DDPictureLoaderUtils.File2FileData(file));
                int w;
                int h;

                DDPictureLoaderUtils.GetSoftImageSize(siHandle, out w, out h);

                {
                    int new_w = w / denom;
                    int new_h = h / denom;
                    int new_si_h = DDPictureLoaderUtils.CreateSoftImage(new_w, new_h);

                    for (int x = 0; x < new_w; x++)
                    {
                        for (int y = 0; y < new_h; y++)
                        {
                            int tR = 0;
                            int tG = 0;
                            int tB = 0;
                            int tA = 0;

                            for (int sx = 0; sx < denom; sx++)
                            {
                                for (int sy = 0; sy < denom; sy++)
                                {
                                    DDPictureLoaderUtils.Dot dot = DDPictureLoaderUtils.GetSoftImageDot(siHandle, x * denom + sx, y * denom + sy);

                                    tR += dot.R;
                                    tG += dot.G;
                                    tB += dot.B;
                                    tA += dot.A;
                                }
                            }
                            double div = (double)(denom * denom);

                            {
                                DDPictureLoaderUtils.Dot dot = new DDPictureLoaderUtils.Dot()
                                {
                                    R = SCommon.ToInt(tR / div),
                                    G = SCommon.ToInt(tG / div),
                                    B = SCommon.ToInt(tB / div),
                                    A = SCommon.ToInt(tA / div),
                                };

                                DDPictureLoaderUtils.SetSoftImageDot(new_si_h, x, y, dot);
                            }
                        }
                    }
                    DDPictureLoaderUtils.ReleaseSoftImage(siHandle);
                    siHandle = new_si_h;
                }

                return DDPictureLoaderUtils.GraphicHandle2Info(DDPictureLoaderUtils.SoftImage2GraphicHandle(siHandle));
            },
                       DDPictureLoaderUtils.ReleaseInfo,
                       DDPictureUtils.Add
                       ));
        }