我目前正在处理图像,有些是DXT压缩的,我需要一个简单的方法来解压和压缩这些文件与Python。不幸的是,我找不到任何能为我做这件事的图书馆。在
有人知道一个很好的Python dxtcompression库,或者一个Compression库的接口吗?在
——dav1d型
编辑:
libsquish是这里的方法,但不幸的是Python绑定不起作用,所以这里是解决方案。在
在C++中制作一个挤压包装器,它导出内部访问函数:
#include <squish.h>
typedef unsigned char u8;
extern "C" {
void CompressMasked( u8 const* rgba, int mask, void* block, int flags ) {
squish::CompressMasked(rgba, mask, block, flags);
}
void Compress( u8 const* rgba, void* block, int flags ) {
squish::Compress(rgba, block, flags);
}
void Decompress( u8* rgba, void const* block, int flags ) {
squish::Decompress(rgba, block, flags);
}
int GetStorageRequirements( int width, int height, int flags ) {
return squish::GetStorageRequirements(width, height, flags);
}
void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags ) {
squish::CompressImage(rgba, width, height, blocks, flags);
}
void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags ) {
squish::DecompressImage(rgba, width, height, blocks, flags);
}
}
创建一个动态库(在windows上是dll,在linux上是这样的,我称之为libsquishc.so
),然后用ctypes
打开它。在
我的方法(只导出我需要的函数):
^{pr2}$
libSquish有{a2}。在
编辑:安装过程似乎
如果您这样做了,但仍然有错误,那么也许您应该(a)共享实际的错误消息,以便我们能够找出原因,或者(b)直接联系补丁作者-mat(at)kivy.org网站在
Edit2:编译错误足够短,我将在这里包括它:
shush.h的相关部分看起来像
^{pr2}$它看起来像是在^ {< CD1>}关键字上阻塞,我想说它是编译成C时编译成C++。在
libsquish提供了一些python绑定:http://code.google.com/p/libsquish/issues/detail?id=17但是我没有使用它们。在
相关问题 更多 >
编程相关推荐