コード例 #1
0
        private void DrawFlip(Bitmap imageBitmap, Graphics g, Bitmap baseBitmap, bool over)
        {
            Bitmap imageBitmap2 = null;

            try
            {
                imageBitmap2 = new Bitmap(imageBitmap.Width, imageBitmap.Height);
                for (int i = 0; i < imageBitmap.Width; i++)
                {
                    for (int j = 0; j < imageBitmap.Height; j++)
                    {
                        Color cc  = imageBitmap.GetPixel(i, j);
                        Color cc2 = over ? Slide.GetTransparencyColor(cc, TransparentColor, TransparentColorTolerance) : cc;
                        imageBitmap2.SetPixel(i, imageBitmap2.Height - j - 1, cc2);
                    }
                }
                int       ddx           = (source_dx <= 0) ? imageBitmap2.Width - source_x : source_dx;
                int       ddy           = (source_dy <= 0) ? imageBitmap2.Height - source_y : source_dy;
                Rectangle srcRectangle  = new Rectangle(source_x, source_y, ddx, ddy);
                Rectangle destRectangle = new Rectangle(x, y, dx, dy);
                g.DrawImage(imageBitmap2, destRectangle, srcRectangle, GraphicsUnit.Pixel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (imageBitmap2 != null)
                {
                    imageBitmap2.Dispose();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Draws the image
        /// </summary>
        /// <param name="source"></param>
        /// <param name="g"></param>
        public override void Draw(string source, Graphics g, Bitmap baseBitmap)
        {
            GetDataFile(source);
            if (LastRaster.X_size <= 0 || LastRaster.Y_size <= 0)
            {
                return;
            }
            int ddx = (source_dx <= 0) ? LastRaster.X_size - source_x : source_dx;
            int ddy = (source_dy <= 0) ? LastRaster.Y_size - source_y : source_dy;

            if (ddx <= 0 || ddy <= 0)
            {
                return;
            }
            Bitmap imageBitmap  = null;
            Bitmap imageBitmap2 = null;

            try
            {
                imageBitmap  = LastRaster.GetBitmap(source_x, source_y, ddx, ddy, this.ParentSlide.BkColor);
                imageBitmap2 = new Bitmap(imageBitmap.Width, imageBitmap.Height);
                for (int i = 0; i < imageBitmap.Width; i++)
                {
                    for (int j = 0; j < imageBitmap.Height; j++)
                    {
                        Color cc  = imageBitmap.GetPixel(i, j);
                        Color cc2 = Slide.GetTransparencyColor(cc, TransparentColor, TransparentColorTolerance);
                        imageBitmap2.SetPixel(i, j, cc2);
                    }
                }
                Rectangle srcRectangle  = new Rectangle(0, 0, ddx, ddy);
                Rectangle destRectangle = new Rectangle(x, y, dx, dy);
                g.DrawImage(imageBitmap2, destRectangle, srcRectangle, GraphicsUnit.Pixel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (imageBitmap != null)
                {
                    imageBitmap.Dispose();
                }
                if (imageBitmap2 != null)
                {
                    imageBitmap2.Dispose();
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Draws the image
        /// </summary>
        /// <param name="source"></param>
        /// <param name="g"></param>
        public override void Draw(string source, Graphics g, Bitmap baseBitmap)
        {
            Bitmap       imageBitmap = null;
            Graphics     tmpG        = null;
            FileStream   fs          = null;
            StreamWriter sw          = null;

            try
            {
                imageBitmap = new Bitmap(dx, dy);
                tmpG        = Graphics.FromImage(imageBitmap);
                Rectangle srcRect = new Rectangle(x, y, dx, dy);
                Rectangle dstRect = new Rectangle(0, 0, dx, dy);
                tmpG.DrawImage(baseBitmap, dstRect, srcRect, GraphicsUnit.Pixel);
                int Count = 0;
                for (int iy = 0; iy < imageBitmap.Height; iy++)
                {
                    for (int ix = 0; ix < imageBitmap.Width; ix++)
                    {
                        Color cc  = imageBitmap.GetPixel(ix, iy);
                        Color cc2 = Slide.GetTransparencyColor(cc, CountColor, CountColorTolerance);
                        if (cc2.A == 0)
                        {
                            Count++;
                        }
                    }
                }
                DirectoryInfo di = new DirectoryInfo(source);
                if (!di.Exists)
                {
                    throw new Exception(source + " not found");
                }
                string saveFile = di.FullName + "\\" + this.Text;
                if (NewFile)
                {
                    fs = File.Open(saveFile, FileMode.Create, FileAccess.Write, FileShare.Read);
                }
                else
                {
                    fs = File.Open(saveFile, FileMode.Append, FileAccess.Write, FileShare.Read);
                }
                sw = new StreamWriter(fs);
                StringBuilder sb = new StringBuilder();
                sb.Append(x.ToString());
                sb.Append(",");
                sb.Append(y.ToString());
                sb.Append(",");
                sb.Append(dx.ToString());
                sb.Append(",");
                sb.Append(dy.ToString());
                sb.Append(",");
                sb.Append(Count.ToString());
                sw.WriteLine(sb.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (imageBitmap != null)
                {
                    imageBitmap.Dispose();
                }
                if (tmpG != null)
                {
                    tmpG.Dispose();
                }
                if (sw != null)
                {
                    sw.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }