我正在使用PngCs dll爲asp.net中的Png圖像文件獲取塊數據,我能夠做到這一點,但現在我想更新該PNG的塊數據。要更改PNG圖像文件的元標記
我使用PngWriter,但它創建整個新文件而不會繼承塊數據。
PngReader pngr = FileHelper.CreatePngReader(path);
pngr.GetMetadata().GetTxtForKey(PngChunkITXT.KEY_Title);
Response.Write(pngr.GetMetadata().GetTxtForKey(PngChunkITXT.KEY_Title));
下面的代碼是通過PngWriter寫入新的PNG圖像,我想嵌入新itxt塊在創建新的文件。
PngReader pngr = FileHelper.CreatePngReader(origFilename); // or you can use the constructor
PngWriter pngw = FileHelper.CreatePngWriter(destFilename, pngr.ImgInfo, true); // idem
Console.WriteLine(pngr.ToString()); // just information
int chunkBehav = ChunkCopyBehaviour.COPY_ALL_SAFE; // tell to copy all 'safe' chunks
pngw.CopyChunksFirst(pngr, chunkBehav); // copy some metadata from reader
for (int row = 0; row < pngr.ImgInfo.Rows; row++)
{
ImageLine l1 = pngr.ReadRowInt(row); // format: RGBRGB... or RGBARGBA...
pngw.WriteRow(l1, row);
}
pngw.CopyChunksLast(pngr, chunkBehav); // metadata after the image pixels? can happen
pngw.End(); // dont forget this
pngr.End();
備查點擊this link
你能發表一些代碼嗎? – mitchfish36
我盡力而爲,請不要沒有任何理由的投票。 – LearningAsp
「而不繼承塊數據。」那是什麼意思?你想要完成什麼,取而代之的是什麼?你想用新的文本塊重寫相同的圖像嗎?請記住,PNG可以包含許多文本(和其他)元數據,您必須決定您想要做什麼。 – leonbloy