jpeg_save_markers() public method

Control saving of COM and APPn markers into Marker_list.
public jpeg_save_markers ( int marker_code, int length_limit ) : void
marker_code int The marker type to save (see JPEG_MARKER enumeration).
/// To arrange to save all the special marker types, you need to call this /// routine 17 times, for COM and APP0-APP15 markers.
length_limit int If the incoming marker is longer than length_limit data bytes, /// only length_limit bytes will be saved; this parameter allows you to avoid chewing up memory /// when you only need to see the first few bytes of a potentially large marker. If you want to save /// all the data, set length_limit to 0xFFFF; that is enough since marker lengths are only 16 bits. /// As a special case, setting length_limit to 0 prevents that marker type from being saved at all. /// (That is the default behavior, in fact.) ///
return void
Example #1
0
        public void TestMarkerList()
        {
            jpeg_decompress_struct cinfo = new jpeg_decompress_struct();
            using (FileStream input = new FileStream(Path.Combine(Tester.Testcase, "PARROTS.JPG"), FileMode.Open))
            {
                /* Specify data source for decompression */
                cinfo.jpeg_stdio_src(input);

                const int markerDataLengthLimit = 1000;
                cinfo.jpeg_save_markers((int)JPEG_MARKER.COM, markerDataLengthLimit);
                cinfo.jpeg_save_markers((int)JPEG_MARKER.APP0, markerDataLengthLimit);

                /* Read file header, set default decompression parameters */
                cinfo.jpeg_read_header(true);

                Assert.AreEqual(cinfo.Marker_list.Count, 3);

                int[] expectedMarkerType = { (int)JPEG_MARKER.APP0, (int)JPEG_MARKER.APP0, (int)JPEG_MARKER.COM };
                int[] expectedMarkerOriginalLength = { 14, 3072, 10 };
                for (int i = 0; i < cinfo.Marker_list.Count; ++i)
                {
                    jpeg_marker_struct marker = cinfo.Marker_list[i];
                    Assert.IsNotNull(marker);
                    Assert.AreEqual(marker.Marker, expectedMarkerType[i]);
                    Assert.AreEqual(marker.OriginalLength, expectedMarkerOriginalLength[i]);
                    Assert.LessOrEqual(marker.Data.Length, markerDataLengthLimit);
                }
            }
        }