예제 #1
0
파일: packrat.cs 프로젝트: gruebait/packrat
 // Process a source image file
 prImg proc( prImg org )
 {
     if( _opts.mipCount != 0 ) {
     if (org.mips == null)
       org.mips = new List<Image>();
     for( int mipLevel = 1, // a modest for loop
      f = (int)Math.Pow(2,mipLevel),
      w = org.mips[0].Width / f,
      h = org.mips[0].Height / f;
      w != 0 && h != 0;
      mipLevel++,
      f = (int) Math.Pow(2, mipLevel),
      w = org.mips[0].Width / f,
      h = org.mips[0].Height / f ) {
       Bitmap mipImg = new Bitmap( w, h );
       Graphics gtemp = Graphics.FromImage( mipImg );
       gtemp.InterpolationMode = _opts.mode;
       gtemp.DrawImage( org.mips[0], new Rectangle( 0, 0, w, h ) );
       gtemp.Dispose();
       org.mips.Add( mipImg );
     }
       }
       if( Processed != null )
     Processed( this, new ImageEventArgs( org.id, org.file ));
       return org;
 }
예제 #2
0
파일: packrat.cs 프로젝트: gruebait/packrat
 // Generate empty mipmaps for the image
 void prepMips( prImg img )
 {
     for (int mipLevel = 1, // mega for-loop
        f = (int) Math.Pow( 2, mipLevel ),
        w = img.mips[0].Width / f,
        h = img.mips[0].Height / f;
        w != 0 && h != 0;
        mipLevel++,
        f = (int) Math.Pow( 2, mipLevel ),
        w = img.mips[0].Width / f,
        h = img.mips[0].Height / f) {
     Bitmap mipImg = new Bitmap( w, h );
     img.mips.Add( mipImg );
       }
 }
예제 #3
0
파일: packrat.cs 프로젝트: gruebait/packrat
 // Add a processed image file to the atlas
 prImg merge( prImg acc, prImg inst )
 {
     int mip = 0;
       //inst.mips.Select(bmp => { return copyMip(mip++, inst, acc); });
       foreach (Image bmp in inst.mips) { copyMip(mip++, inst, acc); }
       if( Packed != null )
     Packed( this, new ImageEventArgs( inst.id, inst.file ) );
       return acc;
 }
예제 #4
0
파일: packrat.cs 프로젝트: gruebait/packrat
 // Prepare the atlas
 prImg prep( string file )
 {
     var img = new Bitmap( Math.Min(_count, _opts.magnitude.Width) * _texSize.Width,
                     (1 + (_count / _opts.magnitude.Width)) * _texSize.Height );
       var pimg = new prImg( file, img, -1 );
       prepMips( pimg );
       return pimg;
 }
예제 #5
0
파일: packrat.cs 프로젝트: gruebait/packrat
 // Copy a specific mip-level from the source image to the atlas
 Image copyMip( int mipLevel, prImg src, prImg dest )
 {
     Graphics g = Graphics.FromImage( dest.mips[ mipLevel ] );
       int w = src.mips[ mipLevel ].Width, h = src.mips[ mipLevel ].Height;
       g.InterpolationMode = _opts.mode;
       g.DrawImage( src.mips[ mipLevel ], (src.id % _opts.magnitude.Width) * w, (src.id / _opts.magnitude.Width) * h );
       g.Dispose();
       return src.mips[ mipLevel ];
 }