GIFToWoWTexture/GIFConverter/TGASharpLib.cs
/// <summary>
/// Update Postage Stamp Image or set it.
/// </summary>
Update Postage Stamp Image or set it.
Update Postage Stamp Image or set it .
public void UpdatePostageStampImage()
        {
            if (Header.ImageType == TgaImageType.NoImageData)
            {
                if (ExtArea != null)
                    ExtArea.PostageStampImage = null;
                return;
            }
            ToNewFormat();
            if (ExtArea.PostageStampImage == null)
                ExtArea.PostageStampImage = new TgaPostageStampImage();
            int PS_Width = Header.ImageSpec.ImageWidth;
            int PS_Height = Header.ImageSpec.ImageHeight;
            if (Width > 64 || Height > 64)
            {
                float AspectRatio = Width / (float)Height;
                PS_Width = (byte)(64f * (AspectRatio < 1f ? AspectRatio : 1f));
                PS_Height = (byte)(64f / (AspectRatio > 1f ? AspectRatio : 1f));
            }
            PS_Width = Math.Max(PS_Width, 4);
            PS_Height = Math.Max(PS_Height, 4);
            ExtArea.PostageStampImage.Width = (byte)PS_Width;
            ExtArea.PostageStampImage.Height = (byte)PS_Height;
            int BytesPerPixel = (int)Math.Ceiling((double)Header.ImageSpec.PixelDepth / 8.0);
            ExtArea.PostageStampImage.Data = new byte[PS_Width * PS_Height * BytesPerPixel];
            float WidthCoef = Width / (float)PS_Width;
            float HeightCoef = Height / (float)PS_Height;
            for (int y = 0; y < PS_Height; y++)
            {
                int Y_Offset = (int)(y * HeightCoef) * Width * BytesPerPixel;
                int y_Offset = y * PS_Width * BytesPerPixel;
                for (int x = 0; x < PS_Width; x++)
                {
                    Buffer.BlockCopy(ImageOrColorMapArea.ImageData, Y_Offset + (int)(x * WidthCoef) * BytesPerPixel,
                        ExtArea.PostageStampImage.Data, y_Offset + x * BytesPerPixel, BytesPerPixel);
                }
            }
        }
public void UpdatePostageStampImage ( ) { if ( Header . ImageType == TgaImageType . NoImageData ) { if ( ExtArea != null ) ExtArea . PostageStampImage = null ; return ; } ToNewFormat ( ) ; if ( ExtArea . PostageStampImage == null ) ExtArea . PostageStampImage = new TgaPostageStampImage ( ) ; int PS_Width = Header . ImageSpec . ImageWidth ; int PS_Height = Header . ImageSpec . ImageHeight ; if ( Width > 64 || Height > 64 ) { float AspectRatio = Width / ( float ) Height ; PS_Width = ( byte ) ( 64f * ( AspectRatio < 1f ? AspectRatio : 1f ) ) ; PS_Height = ( byte ) ( 64f / ( AspectRatio > 1f ? AspectRatio : 1f ) ) ; } PS_Width = Math . Max ( PS_Width , 4 ) ; PS_Height = Math . Max ( PS_Height , 4 ) ; ExtArea . PostageStampImage . Width = ( byte ) PS_Width ; ExtArea . PostageStampImage . Height = ( byte ) PS_Height ; int BytesPerPixel = ( int ) Math . Ceiling ( ( double ) Header . ImageSpec . PixelDepth / 8.0 ) ; ExtArea . PostageStampImage . Data = new byte [ PS_Width * PS_Height * BytesPerPixel ] ; float WidthCoef = Width / ( float ) PS_Width ; float HeightCoef = Height / ( float ) PS_Height ; for ( int y = 0 ; y < PS_Height ; y ++ ) { int Y_Offset = ( int ) ( y * HeightCoef ) * Width * BytesPerPixel ; int y_Offset = y * PS_Width * BytesPerPixel ; for ( int x = 0 ; x < PS_Width ; x ++ ) { Buffer . BlockCopy ( ImageOrColorMapArea . ImageData , Y_Offset + ( int ) ( x * WidthCoef ) * BytesPerPixel , ExtArea . PostageStampImage . Data , y_Offset + x * BytesPerPixel , BytesPerPixel ) ; } } }
Update Postage Stamp Image or set it.
Update Postage Stamp Image or set it .