Exemplo n.º 1
0
        public void png_set_text(png_text text_ptr)
        {
            if (text_ptr.key == null || text_ptr.key == "")
            {
                Debug.WriteLine("Ignoring attempt to set empty text");
                return;
            }

            if (text_ptr.compression <= 0)
            {
                text_ptr.lang     = null;
                text_ptr.lang_key = null;
            }

            if (text_ptr.text == null || text_ptr.text == "")
            {
                if (text_ptr.compression > 0)
                {
                    text_ptr.compression = PNG_TEXT_COMPRESSION.ITXT_COMPRESSION_NONE;
                }
                else
                {
                    text_ptr.compression = PNG_TEXT_COMPRESSION.NONE;
                }
                text_ptr.text = null;
            }

            if (info_ptr_text == null)
            {
                info_ptr_text = new List <png_text>();
            }
            info_ptr_text.Add(text_ptr);
        }
Exemplo n.º 2
0
        // Writes the end of the PNG file. Texts and tIME.
        public void png_write_end()
        {
            if ((mode & PNG_MODE.HAVE_IDAT) != PNG_MODE.HAVE_IDAT)
            {
                throw new PNG_Exception("No IDATs written into file");
            }

            // check to see if user has supplied a time chunk
            if ((info_ptr_valid & PNG_INFO.tIME) == PNG_INFO.tIME)
            {
                png_write_tIME(info_ptr_mod_time);
            }

            // Check to see if we need to write text chunks
            if (info_ptr_text != null)
            {
                for (int i = 0; i < info_ptr_text.Count; i++)
                {
                    // an internationalized chunk?
                    if (info_ptr_text[i].compression > 0)
                    {
                        // write international chunk
                        png_write_iTXt(info_ptr_text[i].compression, info_ptr_text[i].key, info_ptr_text[i].lang, info_ptr_text[i].lang_key, info_ptr_text[i].text);

                        // Mark this chunk as written
                        png_text t = info_ptr_text[i];
                        t.compression    = PNG_TEXT_COMPRESSION.NONE_WR;
                        info_ptr_text[i] = t;
                    }
                    // If we want a compressed text chunk
                    else if (info_ptr_text[i].compression == PNG_TEXT_COMPRESSION.zTXt)
                    {
                        // write compressed chunk
                        png_write_zTXt(info_ptr_text[i].key, info_ptr_text[i].text, info_ptr_text[i].compression);

                        // Mark this chunk as written
                        png_text t = info_ptr_text[i];
                        t.compression    = PNG_TEXT_COMPRESSION.zTXt_WR;
                        info_ptr_text[i] = t;
                    }
                    else if (info_ptr_text[i].compression == PNG_TEXT_COMPRESSION.NONE)
                    {
                        // write uncompressed chunk
                        png_write_tEXt(info_ptr_text[i].key, info_ptr_text[i].text);

                        // Mark this chunk as written
                        png_text t = info_ptr_text[i];
                        t.compression    = PNG_TEXT_COMPRESSION.NONE_WR;
                        info_ptr_text[i] = t;
                    }
                }
            }

            mode |= PNG_MODE.AFTER_IDAT;

            // write end of PNG file
            png_write_IEND();
        }
Exemplo n.º 3
0
		public uint png_get_text(ref png_text[] texts)
		{
			if(info_ptr_text==null||info_ptr_text.Count==0) return 0;
			texts=info_ptr_text.ToArray();
			return (uint)info_ptr_text.Count;
		}
Exemplo n.º 4
0
		public void png_set_text(png_text[] text_ptr)
		{
			if(text_ptr==null||text_ptr.Length==0) return;
			foreach(png_text text_ptr_ in text_ptr) png_set_text(text_ptr_);
		}
Exemplo n.º 5
0
		public void png_set_text(png_text text_ptr)
		{
			if(text_ptr.key==null||text_ptr.key=="")
			{
				Debug.WriteLine("Ignoring attempt to set empty text");
				return;
			}

			if(text_ptr.compression<=0)
			{
				text_ptr.lang=null;
				text_ptr.lang_key=null;
			}

			if(text_ptr.text==null||text_ptr.text=="")
			{
				if(text_ptr.compression>0) text_ptr.compression=PNG_TEXT_COMPRESSION.ITXT_COMPRESSION_NONE;
				else text_ptr.compression=PNG_TEXT_COMPRESSION.NONE;
				text_ptr.text=null;
			}

			if(info_ptr_text==null) info_ptr_text=new List<png_text>();
			info_ptr_text.Add(text_ptr);
		}