Пример #1
0
        public MatteTransform(PixelSource source, Color color, bool allowFormatChange) : base(source)
        {
            Format = source.Format;

            if (Format.ColorRepresentation != PixelColorRepresentation.Bgr || Format.AlphaRepresentation == PixelAlphaRepresentation.None)
            {
                throw new NotSupportedException("Pixel format not supported.  Must be BGRA");
            }

            if (allowFormatChange && Format == PixelFormat.Pbgra128BppLinearFloat && !color.IsTransparent())
            {
                Format = PixelFormat.Bgrx128BppLinearFloat;
            }

            var igtq = LookupTables.SrgbInverseGammaUQ15;

            matteB = igtq[color.B];
            matteG = igtq[color.G];
            matteR = igtq[color.R];
            matteA = Fix15(color.A);

            matteValue32 = (uint)color.ToArgb();
            matteValue64 = ((ulong)matteA << 48) | ((ulong)UnFix15(matteR * matteA) << 32) | ((ulong)UnFix15(matteG * matteA) << 16) | UnFix15(matteB * matteA);

            var igtf = LookupTables.SrgbInverseGamma;
            var atf  = LookupTables.Alpha;

            float mr = igtf[color.R], mg = igtf[color.G], mb = igtf[color.B], maa = atf[color.A];

            vmatte = new Vector4(mb, mg, mr, 1f) * new Vector4(maa);
        }
Пример #2
0
        public OrientationTransformInternal(PixelSource source, Orientation orientation) : base(source)
        {
            bytesPerPixel = source.Format.BytesPerPixel;
            if (!(bytesPerPixel == 1 || bytesPerPixel == 2 || bytesPerPixel == 3 || bytesPerPixel == 4 || bytesPerPixel == 16))
            {
                throw new NotSupportedException("Pixel format not supported.");
            }

            Width  = source.Width;
            Height = source.Height;

            orient = orientation;
            if (orient.SwapsDimensions())
            {
                lineBuff        = BufferPool.Rent(BufferStride);
                (Width, Height) = (Height, Width);
            }

            int bufferStride = MathUtil.PowerOfTwoCeiling(Width * bytesPerPixel, IntPtr.Size);

            if (orient.RequiresCache())
            {
                srcBuff = new PixelBuffer(Height, bufferStride);
            }
        }
 public ColorMatrixTransformInternal(PixelSource source, Matrix4x4 matrix) : base(source)
 {
     vec0 = new Vector4(matrix.M33, matrix.M23, matrix.M13, matrix.M43);
     vec1 = new Vector4(matrix.M32, matrix.M22, matrix.M12, matrix.M42);
     vec2 = new Vector4(matrix.M31, matrix.M21, matrix.M11, matrix.M41);
     vec3 = new Vector4(matrix.M34, matrix.M24, matrix.M14, matrix.M44);
 }
Пример #4
0
        public static ConvolutionTransform <TPixel, TWeight> CreateResize(PixelSource src, int width, int height, InterpolationSettings interpolatorx, InterpolationSettings interpolatory, bool offsetX, bool offsetY)
        {
            var fmt = src.Format;
            var mx  = KernelMap <TWeight> .CreateResample(src.Width, width, interpolatorx, fmt.ChannelCount, offsetX);

            var my = KernelMap <TWeight> .CreateResample(src.Height, height, interpolatory, fmt.ChannelCount == 3? 4 : fmt.ChannelCount, offsetY);

            return(new ConvolutionTransform <TPixel, TWeight>(src, mx, my));
        }
Пример #5
0
        public static ConvolutionTransform <TPixel, TWeight> CreateBlur(PixelSource src, double radius)
        {
            var fmt = src.Format;
            var mx  = KernelMap <TWeight> .CreateBlur(src.Width, radius, fmt.ChannelCount);

            var my = KernelMap <TWeight> .CreateBlur(src.Height, radius, fmt.ChannelCount == 3? 4 : fmt.ChannelCount);

            return(new ConvolutionTransform <TPixel, TWeight>(src, mx, my));
        }
Пример #6
0
        public PadTransformInternal(PixelSource source, Color color, PixelArea innerArea, PixelArea outerArea, bool replay = false) : base(source)
        {
            if (Format.NumericRepresentation != PixelNumericRepresentation.UnsignedInteger || Format.ChannelCount != Format.BytesPerPixel)
            {
                throw new NotSupportedException("Pixel format not supported.");
            }

            fill = (uint)color.ToArgb();

            passthrough = !replay;
            inner       = innerArea;
            Width       = outerArea.Width;
            Height      = outerArea.Height;
        }
Пример #7
0
        public HybridScaleTransform(PixelSource source, int hybridScale) : base(source)
        {
            if (hybridScale == 0 || (hybridScale & (hybridScale - 1)) != 0)
            {
                throw new ArgumentException("Must be power of two", nameof(hybridScale));
            }
            scale = hybridScale;

            BufferStride = PowerOfTwoCeiling(PowerOfTwoCeiling(Width, scale) * Format.BytesPerPixel, IntPtr.Size);
            lineBuff     = ArrayPool <byte> .Shared.Rent(BufferStride *scale);

            Width  = DivCeiling(Source.Width, scale);
            Height = DivCeiling(Source.Height, scale);
        }
Пример #8
0
        private void TransformSpecularGlossiness(AssetContext asset, Texture texture, TextureReferences reference)
        {
            var specularGloss = texture as Texture2D;

            EnsureReadableTexture(specularGloss);
            var diffuse = reference.SmoothnessSource as Texture2D;

            EnsureReadableTexture(diffuse);
            var smoothnessSource =
                reference.SmoothnessTextureChannel == SmoothnessTextureChannel.MetallicOrSpecularAlpha
                    ? specularGloss
                    : diffuse;

            var metallicRoughMapName = GetTextureOutputName(asset.UrhoAssetName, reference);

            using (var fileStream = asset.DestinationFolder.Create(metallicRoughMapName))
            {
                if (fileStream != null)
                {
                    var tmpTexture     = CreateTargetTexture(specularGloss, diffuse);
                    var specularColors =
                        new PixelSource(specularGloss, tmpTexture.width, tmpTexture.height, Color.black);
                    var diffuseColors    = new PixelSource(diffuse, tmpTexture.width, tmpTexture.height, Color.white);
                    var smoothnessColors = specularGloss == smoothnessSource
                        ? specularColors
                        : diffuseColors;
                    var pixels = new Color32[tmpTexture.width * tmpTexture.height];
                    var index  = 0;
                    for (var y = 0; y < tmpTexture.height; ++y)
                    {
                        for (var x = 0; x < tmpTexture.width; ++x)
                        {
                            var mr = PBRUtils.ConvertToMetallicRoughness(new PBRUtils.SpecularGlossiness
                            {
                                diffuse    = diffuseColors.GetAt(x, y),
                                specular   = specularColors.GetAt(x, y),
                                glossiness = smoothnessColors.GetAt(x, y).a,
                                opacity    = 1.0f
                            });
                            pixels[index] = new Color(mr.roughness, mr.metallic, 0, 1);
                            ++index;
                        }
                    }

                    tmpTexture.SetPixels32(pixels, 0);
                    var bytes = tmpTexture.EncodeToPNG();
                    fileStream.Write(bytes, 0, bytes.Length);
                }
            }
        }
        public PlanarConversionTransform(PixelSource srcY, PixelSource srcCb, PixelSource srcCr, Matrix4x4 matrix, bool videoLevels) : base(srcY)
        {
            if (srcCb.Width != srcY.Width || srcCb.Height != srcY.Height)
            {
                throw new ArgumentException("Chroma plane incorrect size", nameof(srcCb));
            }
            if (srcCr.Width != srcY.Width || srcCr.Height != srcY.Height)
            {
                throw new ArgumentException("Chroma plane incorrect size", nameof(srcCr));
            }
            if (srcCb.Format.BitsPerPixel != srcY.Format.BitsPerPixel)
            {
                throw new ArgumentException("Chroma plane incorrect format", nameof(srcCb));
            }
            if (srcCr.Format.BitsPerPixel != srcY.Format.BitsPerPixel)
            {
                throw new ArgumentException("Chroma plane incorrect format", nameof(srcCr));
            }

            matrix = matrix.InvertPrecise();
            if (matrix.IsNaN())
            {
                throw new ArgumentException("Invalid YCC matrix", nameof(matrix));
            }

            sourceCb = srcCb;
            sourceCr = srcCr;

            if (videoLevels)
            {
                matrix *= byte.MaxValue / videoChromaScale;
            }

            coeffCb0 = matrix.M23;
            coeffCb1 = matrix.M22;
            coeffCr0 = matrix.M32;
            coeffCr1 = matrix.M31;

            Format = srcY.Format == PixelFormat.Y8Bpp ? PixelFormat.Bgr24Bpp : PixelFormat.Bgrx128BppFloat;

            int bufferStride = BufferStride;

            if (HWIntrinsics.IsAvxSupported)
            {
                bufferStride = PowerOfTwoCeiling(bufferStride, HWIntrinsics.VectorCount <byte>());
            }

            lineBuff = BufferPool.Rent(bufferStride * 3, true);
        }
        public PlanarConversionTransform(PixelSource srcY, PixelSource srcCb, PixelSource srcCr, Matrix4x4 matrix, bool videoLevels) : base(srcY)
        {
            if (srcCb.Width != srcY.Width || srcCb.Height != srcY.Height)
            {
                throw new ArgumentException("Chroma plane incorrect size", nameof(srcCb));
            }
            if (srcCr.Width != srcY.Width || srcCr.Height != srcY.Height)
            {
                throw new ArgumentException("Chroma plane incorrect size", nameof(srcCr));
            }
            if (srcCb.Format.BitsPerPixel != srcY.Format.BitsPerPixel)
            {
                throw new ArgumentException("Chroma plane incorrect format", nameof(srcCb));
            }
            if (srcCr.Format.BitsPerPixel != srcY.Format.BitsPerPixel)
            {
                throw new ArgumentException("Chroma plane incorrect format", nameof(srcCr));
            }

            matrix = matrix.InvertPrecise();
            if (matrix.IsNaN())
            {
                throw new ArgumentException("Invalid YCC matrix", nameof(matrix));
            }

            sourceCb = srcCb;
            sourceCr = srcCr;

            if (videoLevels)
            {
                matrix.M22 *= byte.MaxValue / videoChromaScale;
                matrix.M23 *= byte.MaxValue / videoChromaScale;
                matrix.M31 *= byte.MaxValue / videoChromaScale;
                matrix.M32 *= byte.MaxValue / videoChromaScale;
            }

            vec0 = new Vector4(matrix.M13, matrix.M23, matrix.M33, 0f);
            vec1 = new Vector4(matrix.M12, matrix.M22, matrix.M32, 0f);
            vec2 = new Vector4(matrix.M11, matrix.M21, matrix.M31, 0f);

            Format = srcY.Format.FormatGuid == Consts.GUID_WICPixelFormat8bppY ? PixelFormat.FromGuid(Consts.GUID_WICPixelFormat24bppBGR) : PixelFormat.Bgrx128BppFloat;
            if (HWIntrinsics.IsAvxSupported)
            {
                BufferStride = PowerOfTwoCeiling(BufferStride, HWIntrinsics.VectorCount <byte>());
            }

            lineBuff = BufferPool.Rent(BufferStride * 3, true);
        }
Пример #11
0
        public void ShowPage()
        {//To render PDF page, finally to the image control.
         //Calculate render size.
            CalcRenderSize();
            PixelSource bitmap = new PixelSource();

            bitmap.Width  = (int)m_iRenderAreaSizeX;
            bitmap.Height = (int)m_iRenderAreaSizeY;
            Windows.Storage.Streams.IRandomAccessStreamWithContentType stream = m_SDKDocument.RenderPageAsync(bitmap, m_iStartX, m_iStartY, m_iRenderAreaSizeX, m_iRenderAreaSizeY, m_iRotation).GetResults();
            if (stream == null)
            {
                //ShowErrorLog("Error: Fail to render page.", ref new UICommandInvokedHandler(this, &demo_view::renderPage::ReturnCommandInvokedHandler),true, FSCRT_ERRCODE_ERROR);
                return;
            }
            Windows.UI.Xaml.Media.Imaging.BitmapImage bmpImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
            bmpImage.SetSource(stream);
            image.Width  = (int)m_iRenderAreaSizeX;
            image.Height = (int)m_iRenderAreaSizeY;
            image.Source = bmpImage;
        }
Пример #12
0
        public WicAnimatedGifEncoder(PipelineContext ctx, WicImageEncoder enc)
        {
            this.ctx = ctx;
            encoder  = enc;

            lastSource = ctx.Source;
            lastFrame  = ctx.ImageContainer.FrameCount - 1;

            EncodeFrame = new BufferFrame(lastSource.Width, lastSource.Height, lastSource.Format);
            for (int i = 0; i < frames.Length; i++)
            {
                frames[i] = new BufferFrame(lastSource.Width, lastSource.Height, lastSource.Format);
            }

            loadFrame(Current);
            Current.Source.Span.CopyTo(EncodeFrame.Source.Span);

            moveToFrame(1);
            loadFrame(Next !);
        }
Пример #13
0
        private void TransformMetallicGlossiness(AssetContext asset, Texture texture, TextureReferences reference)
        {
            var metallicGloss = texture as Texture2D;

            EnsureReadableTexture(metallicGloss);
            var smoothnessSource = reference.SmoothnessSource as Texture2D;

            EnsureReadableTexture(smoothnessSource);

            var metallicRoughMapName = GetTextureOutputName(asset.UrhoAssetName, reference);

            using (var fileStream = asset.DestinationFolder.Create(metallicRoughMapName))
            {
                if (fileStream != null)
                {
                    var tmpTexture = CreateTargetTexture(metallicGloss, reference.SmoothnessSource as Texture2D);

                    var metallicColors = new PixelSource(metallicGloss, tmpTexture.width, tmpTexture.height,
                                                         new Color(0, 0, 0, 0));
                    var smoothnessColors = metallicGloss == smoothnessSource
                        ? metallicColors
                        : new PixelSource(smoothnessSource, tmpTexture.width, tmpTexture.height, new Color(0, 0, 0, 0));
                    var pixels = new Color32[tmpTexture.width * tmpTexture.height];
                    var index  = 0;
                    for (var y = 0; y < tmpTexture.height; ++y)
                    {
                        for (var x = 0; x < tmpTexture.width; ++x)
                        {
                            var r = 1.0f - smoothnessColors.GetAt(x, y).a;
                            var m = metallicColors.GetAt(x, y).r;
                            pixels[index] = new Color(r, m, 0, 1);
                            ++index;
                        }
                    }

                    tmpTexture.SetPixels32(pixels, 0);
                    var bytes = tmpTexture.EncodeToPNG();
                    fileStream.Write(bytes, 0, bytes.Length);
                }
            }
        }
Пример #14
0
        public OverlayTransform(PixelSource source, PixelSource over, int left, int top, bool alpha, bool replay = false) : base(source)
        {
            if (Format.NumericRepresentation != PixelNumericRepresentation.UnsignedInteger || Format.ChannelCount != bytesPerPixel || Format.BytesPerPixel != bytesPerPixel)
            {
                throw new NotSupportedException("Pixel format not supported.");
            }

            if (over.Format != Format)
            {
                throw new NotSupportedException("Sources must be same pixel format.");
            }

            overSource = over;
            offsX      = left;
            offsY      = top;
            copyBase   = !replay;

            if (alpha)
            {
                lineBuff = BufferPool.Rent(over.Width * bytesPerPixel, true);
            }
        }
Пример #15
0
        async void  Preview_ShowPage(int startIndex = -1, int endIndex = 0)
        {
            if (startIndex == -1)
            {
                startIndex = preview_firstVisibleIndex;
                endIndex = preview_nextInvisibleIndex;
            }
            for (int count = startIndex; count < endIndex; count++)
            {
                Button tmp_b = (Button)(preview_grid.Children.ElementAt(count));
                StackPanel tmp_s = (StackPanel)tmp_b.Content;
                Image img = (Image)tmp_s.Children.First();

                PixelSource bitmap = new PixelSource();
                bitmap.Width = (int)m_iRenderAreaSizeX / preview_scaleDown;
                bitmap.Height = (int)m_iRenderAreaSizeY / preview_scaleDown;
                if (!preview_visiblePage.ContainsKey(count))
                {
                    continue;
                }
                Windows.Storage.Streams.IRandomAccessStreamWithContentType stream = await m_SDKDocument.RenderPageAsync(bitmap, 0, 0,  bitmap.Width, bitmap.Height, 0, preview_visiblePage[count]);
                if (stream == null)
                {
                    return;
                }
                Windows.UI.Xaml.Media.Imaging.BitmapImage bmpImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                bmpImage.SetSource(stream);
                img.Source = bmpImage;
            }
        }
Пример #16
0
 public CropTransform(PixelSource source, in PixelArea crop) : base(source)
Пример #17
0
        public ConversionTransform(PixelSource source, ColorProfile?sourceProfile, ColorProfile?destProfile, PixelFormat destFormat, bool videoLevels = false) : base(source)
        {
            var srcProfile = sourceProfile as CurveProfile ?? ColorProfile.sRGB;
            var dstProfile = destProfile as CurveProfile ?? ColorProfile.sRGB;
            var srcFormat  = source.Format;

            processor = null !;

            Format = destFormat;
            if (srcFormat.BitsPerPixel != Format.BitsPerPixel)
            {
                lineBuff = BufferPool.Rent(BufferStride, true);
                lineBuff.AsSpan().Clear();
            }

            if (srcFormat.ColorRepresentation == PixelColorRepresentation.Cmyk && srcFormat.BitsPerPixel == 64 && Format.BitsPerPixel == 32)
            {
                processor = NarrowingConverter.Instance;
            }
            else if (videoLevels && srcFormat.BitsPerPixel == 8 && Format.BitsPerPixel == 8)
            {
                processor = VideoLevelsConverter.Instance;
            }
            else if (srcFormat.Encoding == PixelValueEncoding.Companded && Format.Encoding == PixelValueEncoding.Linear)
            {
                if (Format.NumericRepresentation == PixelNumericRepresentation.Fixed)
                {
                    if (srcFormat.AlphaRepresentation != PixelAlphaRepresentation.None)
                    {
                        processor = srcProfile.GetConverter <byte, ushort>(ConverterDirection.ToLinear).Processor3A;
                    }
                    else
                    {
                        processor = srcProfile.GetConverter <byte, ushort>(ConverterDirection.ToLinear, videoLevels).Processor;
                    }
                }
                else if (srcFormat.NumericRepresentation == PixelNumericRepresentation.UnsignedInteger && Format.NumericRepresentation == PixelNumericRepresentation.Float)
                {
                    if (srcFormat.AlphaRepresentation != PixelAlphaRepresentation.None)
                    {
                        processor = srcProfile.GetConverter <byte, float>(ConverterDirection.ToLinear).Processor3A;
                    }
                    else if (srcFormat.ChannelCount == 3 && Format.ChannelCount == 4)
                    {
                        processor = srcProfile.GetConverter <byte, float>(ConverterDirection.ToLinear).Processor3X;
                    }
                    else
                    {
                        processor = srcProfile.GetConverter <byte, float>(ConverterDirection.ToLinear, videoLevels).Processor;
                    }
                }
                else if (Format.NumericRepresentation == PixelNumericRepresentation.Float)
                {
                    if (srcFormat.AlphaRepresentation != PixelAlphaRepresentation.None)
                    {
                        processor = srcProfile.GetConverter <float, float>(ConverterDirection.ToLinear).Processor3A;
                    }
                    else
                    {
                        processor = srcProfile.GetConverter <float, float>(ConverterDirection.ToLinear).Processor;
                    }
                }
            }
            else if (srcFormat.Encoding == PixelValueEncoding.Linear && Format.Encoding == PixelValueEncoding.Companded)
            {
                if (srcFormat.NumericRepresentation == PixelNumericRepresentation.Fixed)
                {
                    if (srcFormat.AlphaRepresentation != PixelAlphaRepresentation.None)
                    {
                        processor = dstProfile.GetConverter <ushort, byte>(ConverterDirection.FromLinear).Processor3A;
                    }
                    else
                    {
                        processor = dstProfile.GetConverter <ushort, byte>(ConverterDirection.FromLinear).Processor;
                    }
                }
                else if (srcFormat.NumericRepresentation == PixelNumericRepresentation.Float && Format.NumericRepresentation == PixelNumericRepresentation.UnsignedInteger)
                {
                    if (srcFormat.AlphaRepresentation != PixelAlphaRepresentation.None)
                    {
                        processor = dstProfile.GetConverter <float, byte>(ConverterDirection.FromLinear).Processor3A;
                    }
                    else if (srcFormat.ChannelCount == 4 && Format.ChannelCount == 3)
                    {
                        processor = dstProfile.GetConverter <float, byte>(ConverterDirection.FromLinear).Processor3X;
                    }
                    else
                    {
                        processor = dstProfile.GetConverter <float, byte>(ConverterDirection.FromLinear).Processor;
                    }
                }
                else if (srcFormat.NumericRepresentation == PixelNumericRepresentation.Float)
                {
                    if (srcFormat.AlphaRepresentation != PixelAlphaRepresentation.None)
                    {
                        processor = dstProfile.GetConverter <float, float>(ConverterDirection.FromLinear).Processor3A;
                    }
                    else
                    {
                        processor = dstProfile.GetConverter <float, float>(ConverterDirection.FromLinear).Processor;
                    }
                }
            }
            else if (srcFormat.NumericRepresentation == PixelNumericRepresentation.UnsignedInteger && Format.NumericRepresentation == PixelNumericRepresentation.Float)
            {
                if (srcFormat.AlphaRepresentation == PixelAlphaRepresentation.Unassociated)
                {
                    processor = FloatConverter.Widening.InstanceFullRange.Processor3A;
                }
                else if (srcFormat.AlphaRepresentation == PixelAlphaRepresentation.None && srcFormat.ChannelCount == 3 && Format.ChannelCount == 4)
                {
                    processor = FloatConverter.Widening.InstanceFullRange.Processor3X;
                }
                else
                {
                    processor = videoLevels ? FloatConverter.Widening.InstanceVideoRange.Processor : FloatConverter.Widening.InstanceFullRange.Processor;
                }
            }
            else if (srcFormat.NumericRepresentation == PixelNumericRepresentation.Float && Format.NumericRepresentation == PixelNumericRepresentation.UnsignedInteger)
            {
                if (Format.AlphaRepresentation != PixelAlphaRepresentation.None)
                {
                    processor = FloatConverter.Narrowing.Instance.Processor3A;
                }
                else if (srcFormat.AlphaRepresentation == PixelAlphaRepresentation.None && srcFormat.ChannelCount == 4 && Format.ChannelCount == 3)
                {
                    processor = FloatConverter.Narrowing.Instance.Processor3X;
                }
                else
                {
                    processor = FloatConverter.Narrowing.Instance.Processor;
                }
            }
            else if (srcFormat.NumericRepresentation == Format.NumericRepresentation && srcFormat.ChannelCount != Format.ChannelCount)
            {
                if (srcFormat.NumericRepresentation == PixelNumericRepresentation.Float)
                {
                    processor = ChannelChanger <float> .GetConverter(srcFormat.ChannelCount, Format.ChannelCount);
                }
                else if (srcFormat.NumericRepresentation == PixelNumericRepresentation.Fixed)
                {
                    processor = ChannelChanger <ushort> .GetConverter(srcFormat.ChannelCount, Format.ChannelCount);
                }
                else
                {
                    processor = ChannelChanger <byte> .GetConverter(srcFormat.ChannelCount, Format.ChannelCount);
                }
            }

            if (processor is null)
            {
                throw new NotSupportedException("Unsupported pixel format");
            }
        }
Пример #18
0
        public async void ShowPage(int startIndex = -1, int endIndex = 0)
        {//To render PDF page, finally to the image control.	
         //Calculate render size.

            if (startIndex == -1)
            {
                startIndex = firstVisibleIndex;
                endIndex = nextInvisibleIndex;
            }
            for (int count = startIndex; count < endIndex; count++)
            {
				m_SDKDocument.LoadAnnot(visiblePage[count].hPage);
                //show word in wordlist on page
                foreach(wordInfo wInfo in wordInfoList)
                {
                    if(wInfo.annotFlag[count] == false)
                    {
                        addAnnot(count, wInfo.word);
                        wInfo.annotFlag[count] = true;
                    }
			    }
                
                Image img = (Image)(ud_pdfContainer.Children.ElementAt(count));

                PixelSource bitmap = new PixelSource();
                bitmap.Width = m_iRenderAreaSizeX;
                bitmap.Height = m_iRenderAreaSizeY;
                if (!visiblePage.ContainsKey(count))
                {
                    continue;
                }

                pageInfo pginfo = visiblePage[count];
                pginfo.renderState = 0;
                visiblePage[count] = pginfo;
                Windows.Storage.Streams.IRandomAccessStreamWithContentType stream = await m_SDKDocument.RenderPageAsync(bitmap, m_iStartX, m_iStartY, m_iRenderAreaSizeX, m_iRenderAreaSizeY, m_iRotation, visiblePage[count].hPage);
                pginfo.renderState = 1;
                //visiblePage[count] = pginfo;
                if (stream == null)
                {
                    return;
                }
				
				pginfo.bitmap = bitmap.PixelBuffer.ToArray();
				pginfo.bmpHeight = bitmap.Height;
                pginfo.bmpWidth = bitmap.Width;

                if (count >= rSelectPageStartIndex && count <= rSelectPageEndIndex)
                {
                    if(pginfo.hTextPage.pointer == 0)
                    {
                        m_SDKDocument.LoadTextPage(visiblePage[count].hPage, out pginfo.hTextPage);
                    } 
                    visiblePage[count] = pginfo;
                    drawSelection(count);
                }
                else
                {
                    visiblePage[count] = pginfo;
                    Windows.UI.Xaml.Media.Imaging.BitmapImage bmpImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                    bmpImage.SetSource(stream);
                    img.Source = bmpImage;
            	}
				m_SDKDocument.unloadAnnot(visiblePage[count].hPage);
            }
        }
Пример #19
0
        protected ConvolutionTransform(PixelSource source, KernelMap <TWeight> mapx, KernelMap <TWeight> mapy, bool lumaMode = false) : base(source)
        {
            var infmt   = source.Format;
            var workfmt = infmt;

            if (lumaMode)
            {
                if (infmt.ColorRepresentation != PixelColorRepresentation.Grey && infmt.ColorRepresentation != PixelColorRepresentation.Bgr)
                {
                    throw new NotSupportedException("Unsupported pixel format: " + infmt.Name);
                }

                workfmt = infmt.NumericRepresentation == PixelNumericRepresentation.Float ? PixelFormat.Grey32BppFloat :
                          infmt.NumericRepresentation == PixelNumericRepresentation.Fixed ? PixelFormat.Grey16BppUQ15 :
                          infmt.NumericRepresentation == PixelNumericRepresentation.UnsignedInteger ? PixelFormat.Grey8Bpp :
                          throw new NotSupportedException("Unsupported pixel format: " + infmt.Name);
            }

            if (!ProcessorMap.TryGetValue(workfmt, out XProcessor !))
            {
                throw new NotSupportedException("Unsupported pixel format: " + workfmt.Name);
            }

            if (workfmt == PixelFormat.Bgr96BppLinearFloat)
            {
                Format = workfmt = PixelFormat.Bgrx128BppLinearFloat;
            }
            else if (workfmt == PixelFormat.Bgr96BppFloat)
            {
                Format = workfmt = PixelFormat.Bgrx128BppFloat;
            }
            else
            {
                Format = infmt;
            }

            YProcessor = ProcessorMap[workfmt];

            if (HWIntrinsics.IsSupported && (mapx.Samples * mapx.Channels & 3) == 0 && XProcessor is IVectorConvolver vcx)
            {
                XProcessor = vcx.IntrinsicImpl;
            }
            if (HWIntrinsics.IsSupported && (mapy.Samples * mapy.Channels & 3) == 0 && YProcessor is IVectorConvolver vcy)
            {
                YProcessor = vcy.IntrinsicImpl;
            }

            XMap = mapx;
            YMap = mapy;

            if (XMap.Channels != XProcessor.MapChannels || YMap.Channels != YProcessor.MapChannels)
            {
                throw new NotSupportedException("Map and Processor channel counts don't match");
            }

            Width  = mapx.Pixels;
            Height = mapy.Pixels;

            int bpp = workfmt.BytesPerPixel / Unsafe.SizeOf <TPixel>() * Unsafe.SizeOf <TWeight>();

            IntBuff = new PixelBuffer(mapy.Samples, bpp, true, mapy.Samples * mapx.Pixels * bpp);

            if (bufferSource = lumaMode)
            {
                SrcBuff = new PixelBuffer(mapy.Samples, BufferStride, true);

                if (workfmt.IsBinaryCompatibleWith(infmt))
                {
                    WorkBuff = SrcBuff;
                }
                else
                {
                    WorkBuff = new PixelBuffer(mapy.Samples, MathUtil.PowerOfTwoCeiling(source.Width * workfmt.BytesPerPixel, IntPtr.Size), true);
                }
            }
            else
            {
                lineBuff = BufferPool.Rent(BufferStride, true);
            }
        }
Пример #20
0
 public PixelSourceAsIPixelSource(PixelSource src) => source = src;
Пример #21
0
 protected ChainedPixelSource(PixelSource source) : base() => PrevSource = source;
Пример #22
0
 public PixelSourceAsIWICBitmapSource(PixelSource src) => source = src;
Пример #23
0
 public SourceStatsProfiler(PixelSource src) => source = src;