Пример #1
0
    public int GetBufSize()
    {
        int ret = LibJpegTurboBridge.tjDecompressHeader(handle, srcPtr, (UInt32)srcLength, ref _width, ref _height);

        if (ret != 0)
        {
            return(0);
        }
        return(EstimatedBufSize);
    }
Пример #2
0
 public void Close()
 {
     if (initialized)
     {
         pinnedArraySrc.Free();
         LibJpegTurboBridge.tjDestroy(handle);
     }
     _width      = 0;
     _height     = 0;
     initialized = false;
 }
Пример #3
0
 public TurboJpegDecoder(byte[] srcBytes, TurboJpegDecoderBuffer _buffer = null)
 {
     buffer = _buffer;
     if (buffer == null)
     {
         buffer = new TurboJpegDecoderBuffer();
     }
     handle         = LibJpegTurboBridge.tjInitDecompress();
     pinnedArraySrc = GCHandle.Alloc(srcBytes, GCHandleType.Pinned);
     srcPtr         = pinnedArraySrc.AddrOfPinnedObject();
     srcLength      = srcBytes.Length;
     initialized    = true;
 }
Пример #4
0
    public bool Decode(byte[] destBuf)
    {
        if (width == 0 && height == 0)
        {
            GetBufSize();
        }
        if (destBuf.Length < EstimatedBufSize)
        {
            return(false);
        }
        int      ret             = 0;
        GCHandle pinnedArrayDest = GCHandle.Alloc(destBuf, GCHandleType.Pinned);
        IntPtr   destPtr         = pinnedArrayDest.AddrOfPinnedObject();

        ret = LibJpegTurboBridge.tjDecompress2(handle, srcPtr,
                                               (UInt32)srcLength,
                                               destPtr, 0, 0, 0,
                                               (int)LibJpegTurboBridge.TJPF.TJPF_RGB,
                                               LibJpegTurboBridge.TJFLAG_FASTDCT + LibJpegTurboBridge.TJFLAG_BOTTOMUP + LibJpegTurboBridge.TJFLAG_NOREALLOC);
        pinnedArrayDest.Free();
        return(ret == 0);
    }