jpeg_read_header libjpeg 的替代品

发布于 2024-09-30 21:03:54 字数 410 浏览 0 评论 0 原文

所以我在 Windows 上使用 libjpeg 时遇到了一个问题,导致 jpeg_read_header() 崩溃。

问题描述如下(相当搞笑): http:// /sourceforge.net/projects/gnuwin32/forums/forum/74807/topic/1629371?message=4053776

我决定使用第三个选项,该选项不使用 jpeg_stdio_src/dest API。然而,经过多次谷歌搜索,我似乎找不到帖子末尾提到的“将数据输入 libjpeg 的其他方法”,有人能指出我正确的地方吗?

So I'm running into an issue using libjpeg on Windows which causes jpeg_read_header() to crash.

The problem is (fairly hilariously) described here: http://sourceforge.net/projects/gnuwin32/forums/forum/74807/topic/1629371?message=4053776

I've decided on the 3rd option, which is not using jpeg_stdio_src/dest APIs. However, after much googling, I can't seem to find the 'other ways to feed data into libjpeg' mentioned at the end of the post, can anyone point me to the right place?

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

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

发布评论

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

评论(5

树深时见影 2024-10-07 21:03:54

有人举报针对在较新的 Visual Studio 中链接 msvcrt 的问题的解决方法。通过谷歌搜索msvcrt.dll“Visual Studio”找到

Sompe people report a workaround for the issue with linking against msvcrt in newer visual studio's. Found by googling msvcrt.dll "visual studio"

浅唱ヾ落雨殇 2024-10-07 21:03:54

“提供数据的其他方法”之一是以下函数:

  1. jpeg_CreateDecompress
  2. jpeg_read_header
  3. jpeg_start_decompress
  4. jpeg_read_raw_data / jpeg_read_scanlines
  5. jpeg_destroy_decompress

One of the "other ways to feed data" is these functions:

  1. jpeg_CreateDecompress
  2. jpeg_read_header
  3. jpeg_start_decompress
  4. jpeg_read_raw_data / jpeg_read_scanlines
  5. jpeg_destroy_decompress
赠我空喜 2024-10-07 21:03:54

如果我正确理解这个问题,那是因为 Windows 中所有各种文件句柄之间的差异。它们并不都彼此兼容。

这个链接会有帮助吗?它告诉您如何在它们之间进行转换。然后,您可以为该函数提供正确类型的文件句柄并使其运行。

http://www.codeproject.com/KB/files/handles.aspx

或者,不要使用该 jpeg 库并使用另一个库。我可以特别推荐没有,因为我以前不需要使用 jpeg 库。

If I understand the problem correctly it's because of the differences between all the various file handles in windows. They are not all compatible with each other.

Would this link be of help? it tells you how to convert between them all. You can then provide the correct kind of file handle to the function and get it running.

http://www.codeproject.com/KB/files/handles.aspx

Alternatively, don't use that jpeg library and use another. There are none I can specifically recommend as I haven't had a need to use a jpeg library before.

╰つ倒转 2024-10-07 21:03:54

我最近在使用 libjppeg-turbo 时遇到了同样的问题。我不想重新编译库或将 mscvr.dll 链接到我的 vs2015 应用程序。

这个函数对我有用:jpeg_mem_src(...),而不是使用jpeg_stdio_src。由于它不会将任何 C 运行时结构传递给库,因此它工作得很好。函数定义可以在这里找到链接

从内存缓冲区而不是文件获取输入数据,如果您的文件不太大/内存不太重要,那么它就可以工作。

I ran into the same problem recently with libjppeg-turbo. I did not want to recompile the library or link mscvr.dll to my vs2015 app.

This function worked for me: jpeg_mem_src(...) instead of using jpeg_stdio_src. Since it doesn't pass any C runtime structures to the library, it works just fine. The function definition can be found here link

It gets the input data from a memory buffer instead of a file, which works if your file isn't too big/memory isn't too much of a concern.

奈何桥上唱咆哮 2024-10-07 21:03:54

我遇到了类似的问题,并在寻找解决方案时看到了这篇文章。最终,我只是搞乱了代码,因为直接从文件读取对我来说至关重要。为了解决这个问题,我做了以下操作:

// Declare needed structs
struct jpeg_decompress_struct dinfo;
struct jpeg_error_mgr jerr;

// Open file
FILE * infile = fopen("myimage.jpg", "rw");

// Create error manager instance
dinfo.err = jpeg_std_error(&jerr);

// Decompression process
jpeg_create_decompress(&dinfo);
jpeg_stdio_src(&dinfo, infile);
jpeg_read_header(&dinfo, TRUE);

// ... remainder of program

这两个函数在执行此操作后工作正常并且符合预期...我不确定为什么这解决了我的问题,但我会接受它。希望这对其他人有帮助。

I had a similar issue and came across this post when looking for solutions. Ultimately, I just messed around with the code because it was crucial for me to read directly from file. To fix, I did the following:

// Declare needed structs
struct jpeg_decompress_struct dinfo;
struct jpeg_error_mgr jerr;

// Open file
FILE * infile = fopen("myimage.jpg", "rw");

// Create error manager instance
dinfo.err = jpeg_std_error(&jerr);

// Decompression process
jpeg_create_decompress(&dinfo);
jpeg_stdio_src(&dinfo, infile);
jpeg_read_header(&dinfo, TRUE);

// ... remainder of program

The two functions work fine and as expected after doing this... I'm not sure why this fixed my issue, but I'll take it. Hope this helps someone else.

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