Beispiel #1
0
        // Initialize png_ptr structure, and allocate any memory needed
        public static png_struct png_create_write_struct()
        {
            try
            {
                png_struct png_ptr = new png_struct();

                try
                {
                    // initialize zbuf-compression buffer
                    png_ptr.zbuf_size = PNG.ZBUF_SIZE;
                    png_ptr.zbuf      = new byte[png_ptr.zbuf_size];

                    png_ptr.png_set_filter_heuristics(PNG_FILTER_HEURISTIC.DEFAULT, 1, null, null);
                }
                catch (Exception)
                {
                    png_ptr.zbuf = null;
                    png_ptr      = null;
                    return(null);
                }
                return(png_ptr);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #2
0
        // Create a PNG structure for reading, and allocate any memory needed.
        public static png_struct png_create_read_struct()
        {
            try
            {
                png_struct png_ptr = new png_struct();

                try
                {
                    // initialize zbuf - compression buffer
                    png_ptr.zbuf_size = PNG.ZBUF_SIZE;
                    png_ptr.zbuf      = new byte[png_ptr.zbuf_size];

                    switch (zlib.inflateInit(png_ptr.zstream))
                    {
                    case zlib.Z_OK: break;

                    case zlib.Z_MEM_ERROR:
                    case zlib.Z_STREAM_ERROR: throw new PNG_Exception("zlib memory error");

                    default: throw new PNG_Exception("Unknown zlib error");
                    }

                    png_ptr.zstream.out_buf   = png_ptr.zbuf;
                    png_ptr.zstream.next_out  = 0;
                    png_ptr.zstream.avail_out = png_ptr.zbuf_size;
                }
                catch (Exception)
                {
                    png_ptr.zbuf = null;
                    png_ptr      = null;
                }
                return(png_ptr);
            }
            catch (Exception)
            {
                return(null);
            }
        }
		// Create a PNG structure for reading, and allocate any memory needed.
		public static png_struct png_create_read_struct()
		{
			try
			{
				png_struct png_ptr=new png_struct();

				try
				{
					// initialize zbuf - compression buffer
					png_ptr.zbuf_size=PNG.ZBUF_SIZE;
					png_ptr.zbuf=new byte[png_ptr.zbuf_size];

					switch(zlib.inflateInit(png_ptr.zstream))
					{
						case zlib.Z_OK: break;
						case zlib.Z_MEM_ERROR:
						case zlib.Z_STREAM_ERROR: throw new PNG_Exception("zlib memory error");
						default: throw new PNG_Exception("Unknown zlib error");
					}

					png_ptr.zstream.out_buf=png_ptr.zbuf;
					png_ptr.zstream.next_out=0;
					png_ptr.zstream.avail_out=png_ptr.zbuf_size;
				}
				catch(Exception)
				{
					png_ptr.zbuf=null;
					png_ptr=null;
				}
				return png_ptr;
			}
			catch(Exception)
			{
				return null;
			}
		}
		// Initialize png_ptr structure, and allocate any memory needed
		public static png_struct png_create_write_struct()
		{
			try
			{
				png_struct png_ptr=new png_struct();

				try
				{
					// initialize zbuf-compression buffer
					png_ptr.zbuf_size=PNG.ZBUF_SIZE;
					png_ptr.zbuf=new byte[png_ptr.zbuf_size];

					png_ptr.png_set_filter_heuristics(PNG_FILTER_HEURISTIC.DEFAULT, 1, null, null);
				}
				catch(Exception)
				{
					png_ptr.zbuf=null;
					png_ptr=null;
					return null;
				}
				return png_ptr;
			}
			catch(Exception)
			{
				return null;
			}
		}