登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> 程序员学前班[不再更新,只读] >> 主题: gd 库必须要 multithreaded DLL 链接库!     [回主站]     [分站链接]
标题
gd 库必须要 multithreaded DLL 链接库!
clq
浏览(0) + 2007-04-29 18:15:17 发表 编辑

关键字:

gd 库必须要 multithreaded DLL 链接库!

http://www.libgd.org/FAQ#Why_does_bgd.dll_crash_with_my_C_program.3F
--------------------------------------------------
Why does bgd.dll crash with my C program?

You are trying to use gd's stdio library functions with a different C runtime library. Read on for notes on individual compilers.

Microsoft Visual C++: If you want to use gdImageCreateFromPng, gdImagePng, and other functions that take a FILE *, you MUST use Visual C++ 6.0 or earlier and you MUST link with the "multithreaded DLL" runtime library option. If you wish to use the .NET compiler, read the "Borland C++" section for an alternative method.

If you do not take the time to understand this, your program simply will not work! Note: the "multithreaded debug DLL" option is NOT the same thing and will NOT work. If you don't want to use the "multithreaded DLL" runtime library option (see "code generation" under "settings"), then read the "Borland C++" section for an alternative method.

GNU mingw32: you should have no problems. The mingw32 compiler is designed to link your application with msvcrt.dll, the same C runtime library that bgd.dll was linked with. (We build it with mingw32, as it happens.)

GNU cygwin: if you are compiling with -mno-cygwin, see the GNU mingw32 entry, above. If you are linking with the full cygwin runtime library, you might be better off installing gd from source. "configure" and "make install" should work for you as they do on full Unix systems. If you have solved the problem of using a win32 DLL from cygwin, however, you can certainly use bgd.dll using the same techniques described below for Borland C++.

Borland C++: this product apparently provides its own C runtime library, incompatible with Microsoft's msvcrt.dll. You cannot use the FILE * functions in gd.h. However, there is an alternative. The gdImagePngPtr and gdImageCreateFromPngPtr functions provide a way to write image file data to a memory buffer, or load an image from a buffer of image file data. See the next two questions for code samples. How do I load an image file from a buffer in memory? The following C code shows how to load an entire image file into a buffer in memory, then ask gd to read the image from that buffer. Please note that since you are responsible for allocating the buffer, You are also responsible for freeing the buffer with your normal memory management functions.

Note to Borland C++ programmers: this code will allow you to load an image using the bgd.dll library, because no FILE * objects are passed across the DLL boundary.

Of course, there is a gdImageCreateFromJpegPtr function available as well. This particular example loads a PNG image.


--------------------------------------------------
参考

想让程序自动合并图片

先想到了gdi+,可惜一个vc6懒得装psdk。
看别人用perl的gd库很快。于是到gd网站下了win32的动态库,c调用,很简单呀。

可惜vc6编译完,一执行就”bgd.dll” crash了,搜了才发现需要改参数
http://www.libgd.org/FAQ#Why_does_bgd.dll_crash_with_my_C_program.3F

终于可以用了,可惜创建一个大图分配内存太大了,25000*10000基本上2、3G跑不动了。
没辙呀,难道没有一个节省内存的吗?photoshop那种不是处理得蛮好吗

据说gdi+可以限制在100M内存,我有些不相信啊。

坛子里有人回帖让直接用imagemagic的命令行
http://www.imagemagick.org/script/command-line-options.php#append

imagemagic和著名的gd一样,都是很受欢迎的开源库。他的命令行功能丰富,一个+append -append参数就可以很容易的满足我合并图片的要求。

我把他写到curl下载后的批处理中,太解决了我大问题了。
convert.exe c:\gmap\maps\1\0.jpg c:\gmap\maps\1\1.jpg c:\gmap\maps\1\2.jpg +append c:\gmap\maps\1.jpg

大图分配内存上视乎优于gd,等过年有空了再改改代码吧,一定要下下来大图。


来自:KESO\'s阅读
2007-02-11 19:23:34

clq
2007-4-29 18:15:55 发表 编辑

原来崩溃在英文是 crash 呀,惭愧惭愧.
clq
2007-4-29 22:22:54 发表 编辑

有些例子.

[url]
http://www.boutell.com/gd/manual2.0.33.html#reference


总数:2 页次:1/1 首页 尾页  
总数:2 页次:1/1 首页 尾页  


所在合集/目录



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1