All pastes #903732 Raw Edit

Stuff

public text v1 · immutable
·published 2008-02-14 12:59 UTC
rendered paste body
        public void MakeBackground800() {

            int Width;
            int Height;
            int X = 0;
            int Y = 0;
            string file;

            for ( int n = 1; n < 4; n++ ) {
                if ( n == 3 )
                    Height = 88;
                else
                    Height = 256;

                for ( int i = 0; i < 4; i++ ) {
                    Width = 256;
                    file = dir + "\\Output\\800_" + n + "_";

                    if ( i == 3 )
                        file += "d";
                    else if ( i == 2 )
                        file += "c";
                    else if ( i == 1 )
                        file += "b";
                    else if ( i == 0 )
                        file += "a";

                    file += "_loading";

                    MakeImage( file, Width, Height, X, Y );

                    if ( i == 3 ) {
                        X = 0;
                        Width = 32;
                    }
                    else {
                        X += Width;
                    }
                }

                Y += Height;
            }

            button2.Enabled = true;
        }

        public void MakeImage( string file, int Width, int Height, int X, int Y ) {
            img = ( Bitmap ) Image.FromFile( dir + "\\Output\\Original.bmp" );
            nimg = new Bitmap( Width, Height );

            g = Graphics.FromImage( nimg );
            //g.DrawImage( img, new Rectangle( 0, 0, Width, Height ), X, Y, Width, Height, GraphicsUnit.Pixel );
            g.DrawImage( img, new Rectangle( 0, 0, Width, Height ), new Rectangle( X, Y, Width, Height ), GraphicsUnit.Pixel );
            g.Dispose();

            nimg.Save( file + ".bmp", ImageFormat.Bmp );
            timg = DevIL.DevIL.LoadBitmap( file + ".bmp" );
            DevIL.DevIL.SaveBitmap( file + ".tga", timg );

            img.Dispose();
            nimg.Dispose();
            timg.Dispose();

            if ( File.Exists( file + ".bmp" ) )
                File.Delete( file + ".bmp" );

            listBox1.Items.Add( file.Remove( 0, file.LastIndexOf( "\\" ) + 1 ) + " " + Width + "x" + Height + " X: " + X + " Y: " + Y );
        }