_MatchImage() private method

private _MatchImage ( System.Windows.Media.Imaging.BitmapFrame frame, int bitDepth, int width, int height, int bpp ) : int
frame System.Windows.Media.Imaging.BitmapFrame
bitDepth int
width int
height int
bpp int
return int
示例#1
0
        private static BitmapFrame _GetBestMatch(IList <BitmapFrame> frames, int bitDepth, int width, int height)
        {
            int  num   = int.MaxValue;
            int  num2  = 0;
            int  index = 0;
            bool flag  = frames[0].Decoder is IconBitmapDecoder;
            int  num3  = 0;

            while (num3 < frames.Count && num != 0)
            {
                int num4 = flag ? frames[num3].Thumbnail.Format.BitsPerPixel : frames[num3].Format.BitsPerPixel;
                if (num4 == 0)
                {
                    num4 = 8;
                }
                int num5 = Utility._MatchImage(frames[num3], bitDepth, width, height, num4);
                if (num5 < num)
                {
                    index = num3;
                    num2  = num4;
                    num   = num5;
                }
                else if (num5 == num && num2 < num4)
                {
                    index = num3;
                    num2  = num4;
                }
                num3++;
            }
            return(frames[index]);
        }
示例#2
0
        private static BitmapFrame _GetBestMatch(IList <BitmapFrame> frames, int bitDepth, int width, int height)
        {
            PixelFormat format;
            int         bitsPerPixel;
            int         num     = 2147483647;
            int         num1    = 0;
            int         num2    = 0;
            bool        decoder = frames[0].Decoder is IconBitmapDecoder;

            for (int i = 0; i < frames.Count && num != 0; i++)
            {
                if (decoder)
                {
                    format       = frames[i].Thumbnail.Format;
                    bitsPerPixel = format.BitsPerPixel;
                }
                else
                {
                    format       = frames[i].Format;
                    bitsPerPixel = format.BitsPerPixel;
                }
                int num3 = bitsPerPixel;
                if (num3 == 0)
                {
                    num3 = 8;
                }
                int num4 = Utility._MatchImage(frames[i], bitDepth, width, height, num3);
                if (num4 < num)
                {
                    num2 = i;
                    num1 = num3;
                    num  = num4;
                }
                else if (num4 == num && num1 < num3)
                {
                    num2 = i;
                    num1 = num3;
                }
            }
            return(frames[num2]);
        }