public byte[] DecorateSourceWithMetaInformation(
     byte[] source,
     ImageMetaInformation information)
 {
     var metaData = ConvertMetaInformationToByteArray(information);
     return metaData
         .Concat(source)
         .ToArray();
 }
Esempio n. 2
0
        public byte[] DecorateSourceWithMetaInformation(
            byte[] source,
            ImageMetaInformation information)
        {
            var metaData = ConvertMetaInformationToByteArray(information);

            return(metaData
                   .Concat(source)
                   .ToArray());
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
        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);
        }
Esempio n. 6
0
 IEnumerable <byte> ConvertMetaInformationToByteArray(
     ImageMetaInformation metaInformation)
 {
     return(generalNativeApi
            .StructureToByteArray(metaInformation));
 }
 IEnumerable<byte> ConvertMetaInformationToByteArray(
     ImageMetaInformation metaInformation)
 {
     return generalNativeApi
         .StructureToByteArray(metaInformation);
 }
        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);
        }