示例#1
0
        public unsafe void SetImageBufferCustomDisp(IntPtr _buf, int _bw, int _bh, int _bytepp, LineDrawAction _lineDrawAction)
        {
            imgBuf    = _buf;
            imgBw     = _bw;
            imgBh     = _bh;
            imgBytepp = _bytepp;

            lineDrawAction = _lineDrawAction;
        }
示例#2
0
        // 이미지 버퍼 설정
        public unsafe void SetImageBuffer(IntPtr _buf, int _bw, int _bh, int _bytepp, bool _isFloat)
        {
            imgBuf        = _buf;
            imgBw         = _bw;
            imgBh         = _bh;
            imgBytepp     = _bytepp;
            isImgbufFloat = _isFloat;

            lineDrawAction = null;
            if (isImgbufFloat)
            {
                if (imgBytepp == 4)            // 4byte float gray
                {
                    lineDrawAction = ImageBoxUtil.LineDrawActionFloat4;
                }
                else if (imgBytepp == 8)       // 8byte double gray
                {
                    lineDrawAction = ImageBoxUtil.LineDrawActionFloat8;
                }
            }
            else
            {
                if (imgBytepp == 1)            // 1byte gray
                {
                    lineDrawAction = ImageBoxUtil.LineDrawActionByte1;
                }
                else if (imgBytepp == 2)       // 2byte gray (*.hra)
                {
                    lineDrawAction = ImageBoxUtil.LineDrawActionByte2;
                }
                else if (imgBytepp == 3)       // 3byte bgr
                {
                    lineDrawAction = ImageBoxUtil.LineDrawActionByte3;
                }
                else if (imgBytepp == 4)       // rbyte bgra
                {
                    lineDrawAction = ImageBoxUtil.LineDrawActionByte4;
                }
            }
        }
示例#3
0
        // 이미지 버퍼를 디스플레이 버퍼에 복사
        public static unsafe void DrawImageBufferZoom(IntPtr imgBuf, int imgBw, int imgBh, int bytepp, bool bufIsFloat, IntPtr dispBuf, int dispBw, int dispBh, int panx, int pany, double zoom, int bgColor, double floatValueMax, LineDrawAction lineDrawAction, bool useParallel)
        {
            // 인덱스 버퍼 생성
            int[] siys = new int[dispBh];
            int[] sixs = new int[dispBw];
            for (int y = 0; y < dispBh; y++)
            {
                int siy = (int)Math.Floor((y - pany) / zoom);
                siys[y] = (siy < 0 || siy >= imgBh) ? -1 : siy;
            }
            for (int x = 0; x < dispBw; x++)
            {
                int six = (int)Math.Floor((x - panx) / zoom);
                sixs[x] = (six < 0 || six >= imgBw) ? -1 : six;
            }
            int x1Include = sixs.ToList().FindIndex(six => six != -1);
            int x2Exclude = sixs.ToList().FindLastIndex(six => six != -1) + 1;

            if (lineDrawAction == null)
            {
                lineDrawAction = LineDrawActionNone;
            }

            Action <int> LineAction = (y) => {
                int *dp  = (int *)dispBuf + (Int64)dispBw * y;
                int  siy = siys[y];
                if (siy == -1 || x1Include == -1)
                {
                    Util.Memset4((IntPtr)dp, bgColor, dispBw);
                    return;
                }
                if (x1Include > 0)
                {
                    Util.Memset4((IntPtr)dp, bgColor, x1Include);
                }

                byte *sptr = (byte *)imgBuf + (Int64)imgBw * siy * bytepp;
                lineDrawAction(x1Include, x2Exclude, sixs, bytepp, sptr, dp + x1Include, floatValueMax);

                if (x2Exclude < dispBw)
                {
                    Util.Memset4((IntPtr)(dp + x2Exclude), bgColor, dispBw - x2Exclude);
                }
            };

            if (useParallel)
            {
                Parallel.For(0, dispBh, LineAction);
            }
            else
            {
                for (int y = 0; y < dispBh; y++)
                {
                    LineAction(y);
                }
            }
        }