BitMiracle.LibJpeg.Classic.jpeg_decompress_struct.jpeg_stdio_src C# (CSharp) Method

jpeg_stdio_src() public method

Sets input stream.
The caller must have already opened the stream, and is responsible for closing it after finishing decompression.
public jpeg_stdio_src ( Stream infile ) : void
infile Stream The input stream.
return void
        public void jpeg_stdio_src(Stream infile)
        {
            /* The source object and input buffer are made permanent so that a series
            * of JPEG images can be read from the same file by calling jpeg_stdio_src
            * only before the first one.  (If we discarded the buffer at the end of
            * one image, we'd likely lose the start of the next one.)
            * This makes it unsafe to use this manager and a different source
            * manager serially with the same JPEG object.  Caveat programmer.
            */
            if (m_src == null)
            {
                /* first time for this JPEG object? */
                m_src = new my_source_mgr(this);
            }

            my_source_mgr m = m_src as my_source_mgr;
            if (m != null)
                m.Attach(infile);
        }

Usage Example

Example #1
0
 static int[][] getDct(string filename)
 {
     jpeg_decompress_struct cinfo = new jpeg_decompress_struct();
     FileStream objFileStreamHeaderImage = new FileStream(filename, FileMode.Open, FileAccess.Read);
     cinfo.jpeg_stdio_src(objFileStreamHeaderImage);
     cinfo.jpeg_read_header(true);
     var coeffs = cinfo.jpeg_read_coefficients();
     const int size = 64;
     int height = cinfo.Image_height / size;
     int width = cinfo.Image_width / size;
     int[][] result = new int[height * width][];
     var dct = coeffs[0].Access(0, height);
     for (int i = 0; i < height * width; i++)
     {
         result[i] = new int[size];
     }
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < width; j++)
         {
             for (int k = 0; k < 64; k++)
             {
                 result[i * width + j][k] = dct[i][j][k];
             }
         }
     }
     return result;
 }
All Usage Examples Of BitMiracle.LibJpeg.Classic.jpeg_decompress_struct::jpeg_stdio_src