示例#1
0
        private static void RenderGrayscale(
            GrayscaleImageGraphic image,
            RectangleF srcViewableRectangle,
            Rectangle dstViewableRectangle,
            IntPtr pDstPixelData,
            int dstWidth,
            int dstBytesPerPixel)
        {
            fixed(byte *pSrcPixelData = image.PixelData.Raw)
            {
                if (image.InterpolationMode == InterpolationMode.Bilinear)
                {
                    //TODO: if we actually supported >8 bit displays, the LUT part would work ...
                    var   outputLut      = image.GetOutputLut(0, byte.MaxValue);
                    int[] finalLutBuffer = ConstructFinalLut(outputLut, image.ColorMap, image.Invert);

                    fixed(int *pFinalLutData = finalLutBuffer)
                    {
                        ImageInterpolatorBilinear.LutData lutData;
                        lutData.Data = pFinalLutData;
                        lutData.FirstMappedPixelData = outputLut.MinInputValue;
                        lutData.Length = finalLutBuffer.Length;

                        ImageInterpolatorBilinear.Interpolate(
                            srcViewableRectangle,
                            pSrcPixelData,
                            image.Columns,
                            image.Rows,
                            image.BytesPerPixel,
                            image.BitsStored,
                            dstViewableRectangle,
                            (byte *)pDstPixelData,
                            dstWidth,
                            dstBytesPerPixel,
                            IsRotated(image),
                            &lutData,                             //ok because it's a local variable in an unsafe method, therefore it's already fixed.
                            false,
                            false,
                            image.IsSigned);
                    }
                }
            }
        }
示例#2
0
        private static void RenderColor(
            ColorImageGraphic image,
            RectangleF srcViewableRectangle,
            Rectangle dstViewableRectangle,
            IntPtr pDstPixelData,
            int dstWidth,
            int dstBytesPerPixel)
        {
            fixed(byte *pSrcPixelData = image.PixelData.Raw)
            {
                if (image.InterpolationMode == InterpolationMode.Bilinear)
                {
                    int srcBytesPerPixel = 4;

                    if (image.VoiLutsEnabled)
                    {
                        int[] finalLutBuffer = ConstructFinalLut(image.OutputLut, image.Invert);
                        fixed(int *pFinalLutData = finalLutBuffer)
                        {
                            ImageInterpolatorBilinear.LutData lutData;
                            lutData.Data = pFinalLutData;
                            lutData.FirstMappedPixelData = image.OutputLut.MinInputValue;
                            lutData.Length = finalLutBuffer.Length;

                            ImageInterpolatorBilinear.Interpolate(
                                srcViewableRectangle,
                                pSrcPixelData,
                                image.Columns,
                                image.Rows,
                                srcBytesPerPixel,
                                32,
                                dstViewableRectangle,
                                (byte *)pDstPixelData,
                                dstWidth,
                                dstBytesPerPixel,
                                IsRotated(image),
                                &lutData,                                 //ok because it's a local variable in an unsafe method, therefore it's already fixed.
                                true,
                                false,
                                false);
                        }
                    }
                    else
                    {
                        ImageInterpolatorBilinear.Interpolate(
                            srcViewableRectangle,
                            pSrcPixelData,
                            image.Columns,
                            image.Rows,
                            srcBytesPerPixel,
                            32,
                            dstViewableRectangle,
                            (byte *)pDstPixelData,
                            dstWidth,
                            dstBytesPerPixel,
                            IsRotated(image),
                            null,
                            true,
                            false,
                            false);
                    }
                }
            }
        }