示例#1
0
        public void DrawImageClipped(Gdi::Graphics g, Gdi::RectangleF clip)
        {
            clip.Intersect(imageArea);
            float cacheX = clip.X + 0.5f;

            if (offsetX > 0)
            {
                cacheX -= offsetX;
            }
            float cacheY = clip.Y + 0.5f;

            if (offsetY > 0)
            {
                cacheY -= offsetY;
            }
#if WIN32PINVOKE
            using (Gdi::Graphics gImg = Gdi::Graphics.FromImage(this.cache)){
                const int     SRCCOPY = 0x00CC0020;
                System.IntPtr dstDC   = g.GetHdc();
                System.IntPtr srcDC   = GetCacheHdc(dstDC);
                BitBlt(
                    dstDC, (int)clip.X, (int)clip.Y,
                    (int)clip.Width, (int)clip.Height,
                    srcDC, (int)cacheX, (int)cacheY,
                    SRCCOPY
                    );
                g.ReleaseHdc(dstDC);
            }
#else
            Gdi::RectangleF rectI = new Gdi::RectangleF(cacheX, cacheY, clip.Width, clip.Height);
            g.DrawImage(this.cache, clip, rectI, Gdi::GraphicsUnit.Pixel);
#endif
        }
示例#2
0
        /// <summary>
        /// 指定した状態に応じた CheckBox を表示します。
        /// </summary>
        /// <param name="g">描画先の Graphics を指定します。</param>
        /// <param name="state">Check 状態を指定します。</param>
        /// <param name="enabled">CheckBox が有効になっているかどうかを指定します。</param>
        public void DrawBox(Gdi::Graphics g, bool?state, bool enabled)
        {
            Gdi::Rectangle src = rect;

            src.X += 14 * (state == null?1: (bool)state?2: 0);
            src.Y += 14 * (enabled?0:1);
            g.DrawImage(this.image, 0, 0, src, Gdi::GraphicsUnit.Pixel);
        }
示例#3
0
        void ITreeNodeIcon.DrawIcon(Gdi::Graphics g, Gdi::Rectangle rect, TreeNode node)
        {
            switch (this.type)
            {
            case IconType.Image:
                g.DrawImage(this.img, rect);
                break;

            case IconType.Icon:
                g.DrawIcon(this.icon, rect);
                break;

            case IconType.ImageList:
                g.DrawImage(this.list.Images[this.index], rect);
                break;

            case IconType.ClippedImage:
                g.DrawImage(this.img, rect, this.rect, Gdi::GraphicsUnit.Pixel);
                break;
            }
        }
示例#4
0
        private void Draw(Gdi::Graphics g)
        {
            if (this.bmp != null)
            {
                //g.DrawLine(Gdi::Pens.Blue,0,0,100,100);

                /*
                 * g.DrawImageUnscaledAndClipped(
                 *      bmp,
                 *      new Gdi::Rectangle(0,0,this.Width,this.Height)
                 *      );
                 * //*/
                g.Clear(this.BackColor);
                g.DrawImage(this.bmp, rcDest, rcSrc, Gdi::GraphicsUnit.Pixel);
            }
        }
示例#5
0
文件: Form2.cs 项目: akinomyoga/hnk
 void UpdatePictureImage()
 {
     if (this.targetImage != null && this.backImage != null)
     {
         using (Gdi::Graphics g = Gdi::Graphics.FromImage(this.backImage)){
             double sx = (double)this.targetImage.Width / this.backImage.Width;
             double sy = (double)this.targetImage.Height / this.backImage.Height;
             double s  = System.Math.Max(sx, sy) * 1.2;
             float  x  = (float)System.Math.Round(0.5 * (this.backImage.Width - this.targetImage.Width / s));
             float  y  = (float)System.Math.Round(0.5 * (this.backImage.Height - this.targetImage.Height / s));
             float  w  = (float)System.Math.Round(this.targetImage.Width / s);
             float  h  = (float)System.Math.Round(this.targetImage.Height / s);
             g.Clear(Gdi::Color.Transparent);
             g.DrawImage(this.targetImage, x, y, w, h);
             this.deform.SetRectangle(x, y, w, h);
             this.deform.imageWidth  = this.targetImage.Width;
             this.deform.imageHeight = this.targetImage.Height;
             this.deform.Draw(this.foreGraphics);
         }
     }
 }
示例#6
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);
        }