如何实现图像或pdf查看器?

发布于 2024-09-12 10:43:42 字数 509 浏览 7 评论 0原文

出于学习目的,我想知道如何自己实现图像(和/或)pdf 查看器。

我对实现此类事情的一般方法感兴趣。

我已经在网上阅读了有关不同格式的信息(tiff/pdf),所以我发现这些文件有一种特殊的格式,它描述了我必须在哪里寻找页眉、页脚在哪里以及图像信息(以解密形式) ) 是。

因为我认为这样的观众是在做某事。例如:

  • 打开文件
  • 读取不同的文件信息(页眉、页脚等)
  • “翻译”像素位置

我需要知道如何获取像素位置(如果是 tiff 文件)。

如何创建它作为控件?我必须将像素放在哪里?

如果我错了,请随时纠正我,因为我对 ATM 并没有真正的想法,一切都只是猜测。

问候,

inno

P.S.:我更喜欢 C# 的解决方案,但如果是其他语言,也可以。平台应该是 Microsoft Windows(首先)。

PPS:它应该在没有安装 pdf/查看应用程序的情况下工作。

for learning purposes I would like to know how to implement an image (and/or) pdf viewer on my own.

I'm interested in the general approach to implement such a thing.

I already read about the different formats on the net (tiff/pdf) so I found out that these files have a special format which describes where I have to look for a header, where the footer is and where the image information (in decrypted form) is.

Because I think such a viewer works sth. like:

  • opening the file
  • reading different file information (header, footer, etc.)
  • "translate" pixel positions

I need to know, how to get the pixel positions (in case of a tiff file).

How to create this as a control? Where do I have to put the pixels onto?

Feel free to correct me if I'm wrong, because ATM I don't really have an idea and everything is just speculation.

Regards,

inno

P.S.: I would prefer a solution in C#, but if it's in another language, it's ok, too. Platform should be Microsoft Windows (first of all).

P.P.S.: It should work without an already installed pdf-/viewing-application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝咒 2024-09-19 10:43:42

对于任何类似的查看器,您都必须查找要显示的每种文件类型的规格,并弄清楚其数据的编码方式。某些图像格式建立在其他图像格式的基础上,或使用类似的编码技术,而其他图像格式则彼此完全不同。 PDF 是另一个野兽。我已经用它做了一些工作,据我所知(我可能是错的,已经有一段时间了),它基本上将自己表示为一系列对象,每个对象都有独特的位置、大小和取决于对象类型的各种属性。

我会看一下维基百科。它实际上有一些关于某些不同图像格式的非常好的文章。

http://en.wikipedia.org/wiki/JPEG

它肯定会指向您您想要涵盖的每种格式的官方标准文档。

最终,您可能最终必须阅读/实现每种格式的 rfc:

JPEG - https:/ /www.rfc-editor.org/rfc/rfc1341
PNG - http://www.faqs.org/rfcs/rfc2083.html< br>
GIF - http://www.w3.org/Graphics/GIF/spec- gif89a.txt
BMP - http://www.faqs.org/rfcs/rfc797.html

HTH

For any viewer like that you will have to look up the specs for each file type you want to display and figure out how its data is encoded. Some image formats build on others, or use similar encoding techniques, while others are completely different from each other. PDF is another beast. I've done a bit of work with it and from what I remember (I could be wrong, it's been a while) it basically represents itself as a series of objects, each with unique position, size and assorted attributes dependent on the object type.

I would take a look at Wikipedia. It actually has some really good articles on some of the different image formats.

http://en.wikipedia.org/wiki/JPEG

And it will definitely point you to the official standards documents for each format you want to cover.

Ultimately you will probably end up having to read/implement the rfc for each format:

JPEG - https://www.rfc-editor.org/rfc/rfc1341
PNG - http://www.faqs.org/rfcs/rfc2083.html
GIF - http://www.w3.org/Graphics/GIF/spec-gif89a.txt
BMP - http://www.faqs.org/rfcs/rfc797.html

HTH

音盲 2024-09-19 10:43:42

这是将图像转换为字节数组的方法。

 public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
 MemoryStream ms = new MemoryStream();
 imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
 return  ms.ToArray();
}

如何创建它作为控件?我必须将像素放在哪里?
这个字节数组包含你的图像像素数据。(看看你的图像类型是8位还是16位)
现在您可以将图像绘制到任何面板中并将其作为自定义控件。

不知道pdf格式怎么样。

Here is the way for converting your image into byte array.

 public byte[] imageToByteArray(System.Drawing.Image imageIn)
{
 MemoryStream ms = new MemoryStream();
 imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
 return  ms.ToArray();
}

How to create this as a control? Where do I have to put the pixels onto?
this byte array contains your image pixel data.(See what is your image type 8bit or 16 bit)
Now you can draw your images into any panel and make it as a custom control.

I don't know about the pdf format.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文