Beispiel #1
0
        private void DrawRectangle(KleiTextureAtlasElement element)
        {
            int x, y, width, height;

            x = element.ImgHmin;
            y = element.ImgVmin;

            /* INVERT THE Y-AXIS */
            if (element.ImgVmin > element.ImgVmax)
            {
                y = element.ImgVmax;
            }

            width  = element.ImgHmax - element.ImgHmin;
            height = Math.Abs(element.ImgVmax - element.ImgVmin);

            graphicsPath = new GraphicsPath();
            graphicsPath.AddRectangle(new Rectangle(x, y, width, height));

            atlasElementWidthToolStrip.Text  = width.ToString();
            atlasElementHeightToolStrip.Text = height.ToString();
            atlasElementXToolStrip.Text      = x.ToString();
            atlasElementYToolStrip.Text      = y.ToString();

            imageBox.Invalidate();
        }
        private void atlasElementsListToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var element = (KleiTextureAtlasElement)atlasElementsListToolStripComboBox.ComboBox.SelectedItem;

            if (element != null)
            {
                DrawRectangle(element);
                element_selected = element;
            }
        }
        public void SaveFileSingle(string FilePath, KleiTextureAtlasElement arg)
        {
            Rectangle cropRect  = new Rectangle(arg.ImgHmin, arg.ImgVmin, arg.ImgHmax - arg.ImgHmin, arg.ImgVmax - arg.ImgVmin);
            Bitmap    SigleFile = new Bitmap(arg.ImgHmax - arg.ImgHmin, arg.ImgVmax - arg.ImgVmin);

            using (Graphics g = Graphics.FromImage(SigleFile))
            {
                g.DrawImage(CurrentFileRaw, 0, 0, cropRect, GraphicsUnit.Pixel);
            }
            SigleFile.Save(FilePath);
        }