public PNG_INFO png_get_pCAL(ref string purpose, ref int X0, ref int X1, ref PNG_EQUATION type, ref string units, ref string[] @params) { if ((info_ptr_valid & PNG_INFO.pCAL) != PNG_INFO.pCAL) { return(PNG_INFO.None); } purpose = info_ptr_pcal_purpose; X0 = info_ptr_pcal_X0; X1 = info_ptr_pcal_X1; type = info_ptr_pcal_type; units = info_ptr_pcal_units; @params = info_ptr_pcal_params; return(PNG_INFO.pCAL); }
public void png_set_pCAL(string purpose, int X0, int X1, PNG_EQUATION type, string units, string[] @params) { if (purpose == null || purpose.Length == 0) { Debug.WriteLine("Ignoring attempt to set unnamed pCal calibration"); return; } info_ptr_pcal_purpose = purpose; info_ptr_pcal_X0 = X0; info_ptr_pcal_X1 = X1; info_ptr_pcal_type = type; info_ptr_pcal_units = units; info_ptr_pcal_params = @params; // TODO: params in array must be set to valid parameters info_ptr_valid |= PNG_INFO.pCAL; }
public PNG_INFO png_get_pCAL(ref string purpose, ref int X0, ref int X1, ref PNG_EQUATION type, ref string units, ref string[] @params) { if((info_ptr_valid&PNG_INFO.pCAL)!=PNG_INFO.pCAL) return PNG_INFO.None; purpose=info_ptr_pcal_purpose; X0=info_ptr_pcal_X0; X1=info_ptr_pcal_X1; type=info_ptr_pcal_type; units=info_ptr_pcal_units; @params=info_ptr_pcal_params; return PNG_INFO.pCAL; }
public void png_set_pCAL(string purpose, int X0, int X1, PNG_EQUATION type, string units, string[] @params) { if(purpose==null||purpose.Length==0) { Debug.WriteLine("Ignoring attempt to set unnamed pCal calibration"); return; } info_ptr_pcal_purpose=purpose; info_ptr_pcal_X0=X0; info_ptr_pcal_X1=X1; info_ptr_pcal_type=type; info_ptr_pcal_units=units; info_ptr_pcal_params=@params; // TODO: params in array must be set to valid parameters info_ptr_valid|=PNG_INFO.pCAL; }
// write the pCAL chunk (described in the PNG extensions document) void png_write_pCAL(string purpose, int X0, int X1, PNG_EQUATION type, string units, string[] @params) { if(units==null||@params==null) return; if(type>=PNG_EQUATION.LAST) Debug.WriteLine("Unrecognized equation type for pCAL chunk"); byte[] new_purpose=null; uint purpose_len=png_check_keyword(purpose, ref new_purpose)+1; uint units_len=(uint)(units.Length+(@params.Length==0?0:1)); uint total_len=purpose_len+units_len+10; uint[] params_len=new uint[@params.Length]; // Find the length of each parameter, making sure we don't count the // null terminator for the last parameter. for(int i=0; i<@params.Length; i++) { params_len[i]=(uint)(@params[i].Length+([email protected]?0:1)); total_len+=params_len[i]; } byte[] buf=new byte[10]; png_write_chunk_start(PNG.pCAL, (uint)total_len); png_write_chunk_data(new_purpose, purpose_len); png_save_int_32(buf, X0); png_save_int_32(buf, 4, X1); buf[8]=(byte)type; buf[9]=(byte)@params.Length; png_write_chunk_data(buf, 10); png_write_chunk_data(Encoding.ASCII.GetBytes(units), units_len); new_purpose=null; for(int i=0; i<@params.Length; i++) png_write_chunk_data(Encoding.ASCII.GetBytes(@params[i]), params_len[i]); png_write_chunk_end(); }