コード例 #1
0
 public byte[] DecorateSourceWithMetaInformation(
     byte[] source,
     ImageMetaInformation information)
 {
     var metaData = ConvertMetaInformationToByteArray(information);
     return metaData
         .Concat(source)
         .ToArray();
 }
コード例 #2
0
        public byte[] DecorateSourceWithMetaInformation(
            byte[] source,
            ImageMetaInformation information)
        {
            var metaData = ConvertMetaInformationToByteArray(information);

            return(metaData
                   .Concat(source)
                   .ToArray());
        }
コード例 #3
0
        static BitmapSource GenerateBitmapSource(
            ImageMetaInformation metaInformation,
            byte[] imageData)
        {
            var bytesPerPixel = (metaInformation.PixelFormat.BitsPerPixel + 7) / 8;
            var stride        = bytesPerPixel * metaInformation.Width;

            return(BitmapSource.Create(
                       metaInformation.Width,
                       metaInformation.Height,
                       metaInformation.DpiX,
                       metaInformation.DpiY,
                       metaInformation.PixelFormat,
                       null,
                       imageData,
                       stride));
        }
コード例 #4
0
        public byte[] ConvertBitmapSourceToByteArray(BitmapSource bitmap)
        {
            if (bitmap == null)
            {
                return(null);
            }

            var metaInformation = new ImageMetaInformation
            {
                DpiX        = bitmap.DpiX,
                DpiY        = bitmap.DpiY,
                Width       = bitmap.PixelWidth,
                Height      = bitmap.PixelHeight,
                PixelFormat = bitmap.Format
            };

            var imageData = ConvertImageDataToByteArray(bitmap);

            return(DecorateSourceWithMetaInformation(
                       imageData, metaInformation));
        }
コード例 #5
0
        public byte[] ConvertBitmapSourceToByteArray(BitmapSource bitmap)
        {
            if (bitmap == null)
            {
                return null;
            }

            var metaInformation = new ImageMetaInformation
            {
                DpiX = bitmap.DpiX,
                DpiY = bitmap.DpiY,
                Width = bitmap.PixelWidth,
                Height = bitmap.PixelHeight,
                PixelFormat = bitmap.Format
            };

            var imageData = ConvertImageDataToByteArray(bitmap);
            return DecorateSourceWithMetaInformation(
                imageData,
                metaInformation);
        }
コード例 #6
0
 IEnumerable <byte> ConvertMetaInformationToByteArray(
     ImageMetaInformation metaInformation)
 {
     return(generalNativeApi
            .StructureToByteArray(metaInformation));
 }
コード例 #7
0
 IEnumerable<byte> ConvertMetaInformationToByteArray(
     ImageMetaInformation metaInformation)
 {
     return generalNativeApi
         .StructureToByteArray(metaInformation);
 }
コード例 #8
0
        static BitmapSource GenerateBitmapSource(
            ImageMetaInformation metaInformation,
            byte[] imageData)
        {
            var bytesPerPixel = (metaInformation.PixelFormat.BitsPerPixel + 7)/8;
            var stride = bytesPerPixel*metaInformation.Width;

            return BitmapSource.Create(
                metaInformation.Width,
                metaInformation.Height,
                metaInformation.DpiX,
                metaInformation.DpiY,
                metaInformation.PixelFormat,
                null,
                imageData,
                stride);
        }