Ejemplo n.º 1
0
        public static void UpdateFrames(Gdi::Image image)
        {
            if (!anyFrameDirty || image == null || imageInfoList == null || WriterLockWait.Count > 0)
            {
                return;
            }

            using (new ReaderLock(rwImgListLock)){
                bool f_isdirty = false;
                bool f_updated = false;
                foreach (ImageInfo info in imageInfoList)
                {
                    if (info.Image == image)
                    {
                        info.UpdateFrame();
                        f_updated = true;
                    }
                    if (info.FrameDirty)
                    {
                        f_isdirty = true;
                    }
                    if (f_isdirty && f_updated)
                    {
                        break;
                    }
                }
                anyFrameDirty = f_isdirty;
            }
        }
Ejemplo n.º 2
0
 public ImageInfo(Gdi::Image image)
 {
     this.image    = image;
     this.animated = ImageAnimator.CanAnimate(image);
     if (this.animated)
     {
         this.frameCount = image.GetFrameCount(Gdi::Imaging.FrameDimension.Time);
         Gdi::Imaging.PropertyItem propertyItem = image.GetPropertyItem(PROPERTY_TagFrameDelay);
         if (propertyItem != null)
         {
             byte[] buffer = propertyItem.Value;
             this.frameDelay = new int[this.frameCount];
             for (int i = 0; i < this.frameCount; i++)
             {
                 int val = buffer[i * 4] | buffer[i * 4 + 1] << 8 | buffer[i * 4 + 2] << 16 | buffer[i * 4 + 3] << 24;
                 this.frameDelay[i] = val > 0?val:1;                         // 最小でも 1
             }
         }
     }
     else
     {
         this.frameCount = 1;
     }
     if (this.frameDelay == null)
     {
         this.frameDelay = new int[this.frameCount];
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// System.Drawing.Image でアイコンを設定します。
 /// </summary>
 /// <param name="value">設定するアイコンを指定します。</param>
 public void SetImage(Gdi::Image value)
 {
     //if(type==IconType.Image&&img==value)return;
     this.type = IconType.Image;
     img       = value;
     icon      = null;
     list      = null;
 }
Ejemplo n.º 4
0
 //============================================================
 //		画像の設定
 //============================================================
 /// <summary>
 /// System.Drawing.Icon でアイコンを設定します。
 /// </summary>
 /// <param name="value">設定するアイコンを指定します。</param>
 public void SetIcon(Gdi::Icon value)
 {
     //if(type==IconType.Icon&&icon==value)return;
     this.type = IconType.Icon;
     icon      = value;
     img       = null;
     list      = null;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// ImageList に登録されている画像をアイコンとして使用します。
 /// </summary>
 /// <param name="list">使用する画像を含んでいる ImageList を指定します。</param>
 /// <param name="index">使用する画像の ImageList の中に於ける番号を指定します。</param>
 public void SetImage(Forms::ImageList list, int index)
 {
     //if(this.type==IconType.ImageList&&this.list==list&&this.index=index)return;
     this.type  = IconType.ImageList;
     this.list  = list;
     this.index = index;
     this.icon  = null;
     this.img   = null;
 }
Ejemplo n.º 6
0
 //============================================================
 //		ロード
 //============================================================
 /// <summary>
 /// 画像をファイルパスを指定して読み込みます。
 /// </summary>
 /// <param name="path">読み込む画像ファイルへのパスを指定します。</param>
 public void LoadImageFromFile(string path)
 {
     try{
         this.Image       = Gdi::Bitmap.FromFile(path);
         this.bmp_autodel = true;
     }catch {
         // TODO: ErrorImage
         this.Image = null;
     }
 }
Ejemplo n.º 7
0
        public static void UpdateFrames(Gdi::Image image)
        {
            if (image == null || imageInfoList == null || WriterLockWait.Count > 0)
            {
                return;
            }

            using (new ReaderLock(rwImgListLock)){
                foreach (ImageInfo info in imageInfoList)
                {
                    if (info.Image == image)
                    {
                        info.UpdateFrame();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public static bool CanAnimate(Gdi::Image image)
        {
            if (image == null)
            {
                return(false);
            }

            lock (image){
                foreach (System.Guid guid in image.FrameDimensionsList)
                {
                    Gdi::Imaging.FrameDimension dimension = new Gdi::Imaging.FrameDimension(guid);
                    if (dimension.Equals(Gdi::Imaging.FrameDimension.Time))
                    {
                        return(image.GetFrameCount(Gdi::Imaging.FrameDimension.Time) > 1);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 描画する背景画像の情報を更新します。
        /// </summary>
        /// <param name="image">描画する背景画像を指定します。</param>
        /// <param name="scaleX">画像の表示 X 倍率を指定します。</param>
        /// <param name="scaleY">画像の表示 Y 倍率を指定します。</param>
        /// <param name="offsetX">画像の表示 X 位置を指定します。</param>
        /// <param name="offsetY">画像の表示 Y 位置を指定します。</param>
        /// <param name="displaySize">画面上の表示の大きさを指定します。</param>
        public void UpdateImage(Gdi::Image image, float scaleX, float scaleY, float offsetX, float offsetY, Gdi::Size displaySize)
        {
            if (image == this.original &&
                scaleX == this.scaleX && scaleY == this.scaleY &&
                offsetX == this.offsetX && offsetY == this.offsetY &&
                displaySize == this.displaySize
                )
            {
                return;
            }

            this.original    = image;
            this.scaleX      = scaleX;
            this.scaleY      = scaleY;
            this.offsetX     = offsetX;
            this.offsetY     = offsetY;
            this.displaySize = displaySize;

            imageArea = new Gdi::RectangleF(offsetX, offsetY, image.Width * scaleX, image.Height * scaleY);
            // 画面座標での描画領域
            Gdi::RectangleF srcRectD = Gdi::RectangleF.Intersect(new Gdi::RectangleF(Gdi::PointF.Empty, displaySize), imageArea);
            // 画像座標での描画領域
            Gdi::RectangleF srcRectI = new Gdi::RectangleF(
                (srcRectD.X - offsetX) / scaleX,
                (srcRectD.Y - offsetY) / scaleY,
                srcRectD.Width / scaleX,
                srcRectD.Height / scaleY
                );

            srcRectD.X = 0;
            srcRectD.Y = 0;

            this.FreeCache();
            this.cache = new System.Drawing.Bitmap((int)(srcRectD.Width + .5f), (int)(srcRectD.Height + .5f));
            using (Gdi::Graphics g = Gdi::Graphics.FromImage(this.cache))
                g.DrawImage(image, srcRectD, srcRectI, Gdi::GraphicsUnit.Pixel);

            ImageEnlight(this.cache);
        }
Ejemplo n.º 10
0
        public static void Animate(Gdi::Image image, System.EventHandler onFrameChangedHandler)
        {
            if (image == null)
            {
                return;
            }

            ImageInfo item = null;

            lock (image) item = new ImageInfo(image);

            StopAnimate(image, onFrameChangedHandler);

            WriterLock w_lock;

            using (new WriterLockWait())
                w_lock = new WriterLock(rwImgListLock);

            using (w_lock){
                if (!item.animated)
                {
                    return;
                }

                if (imageInfoList == null)
                {
                    imageInfoList = new Gen::List <ImageInfo>();
                }
                item.onFrameChangedHandler = onFrameChangedHandler;
                imageInfoList.Add(item);
                if (animationThread == null)
                {
                    animationThread              = new Thr::Thread(new Thr::ThreadStart(ImageAnimator.AnimateImages50ms));
                    animationThread.Name         = typeof(ImageAnimator).Name;
                    animationThread.IsBackground = true;
                    animationThread.Start();
                }
            }
        }
Ejemplo n.º 11
0
        public static void StopAnimate(Gdi::Image image, System.EventHandler onFrameChangedHandler)
        {
            if (image == null || imageInfoList == null)
            {
                return;
            }

            WriterLock w_lock;

            using (new WriterLockWait())
                w_lock = new WriterLock(rwImgListLock);

            using (w_lock){
                ImageInfo item = imageInfoList.Find(delegate(ImageInfo info){ return(image == info.Image); });
                if (item == null)
                {
                    return;
                }
                if (onFrameChangedHandler == item.onFrameChangedHandler || onFrameChangedHandler != null && onFrameChangedHandler.Equals(item.onFrameChangedHandler))
                {
                    imageInfoList.Remove(item);
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 画像の一部をアイコンとして設定します。
 /// </summary>
 /// <param name="image">元となる画像を指定します。</param>
 /// <param name="rect">アイコンとして使用する画像の部分を指定する矩形を指定します。</param>
 public void SetImage(Gdi::Image image, Gdi::Rectangle rect)
 {
     this.type = IconType.ClippedImage;
     this.img  = image;
     this.rect = rect;
 }
Ejemplo n.º 13
0
 private TreeNodeCheckBox(Gdi::Image image, Gdi::Rectangle rect)
 {
     this.image = image;
     this.rect  = rect;
 }