请问那里有显示,操作,保存,TIFF 文件的库可供免费下载(up 有分)

peterleex 上海华东师范大学 2003-07-08 09:44:28
codeproject 的那个 Graphics-Suite 不好用
...全文
8 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ayixidaiyilu 2003-11-13
ok
回复
Skt32 2003-07-14
Tag Image File Format (TIFF) files are used for a diverse set of applications such as GIS (geographic information systems), CAD drawing programs, etc... Fortunately for programmers like us, a portable and easy to use library is freely available, from www.libtiff.org, for decoding the information stored in TIFF files.

This article outlines and provides an implementation of a simple approach that will allow you to include support for TIFF files in your applications with a few library calls.

Here is an outline of the approach:

Use the "TIFFOpen" call passing in a filename and io mode.
Use the "TIFFGetField" function to read the image height and width tags, then allocate the required space (WxHx4).
Use "TIFFReadRGBAImage" to copy the actual pixel data from the file to the space you just allocated.
Copy the raster data to a Device Independent Bitmap (DIB) using care to maintain the picture layout.
Delete the allocated space for the pixel data.
Call "TIFFClose" to free resources allocated in the library.
Draw the DIB to the screen.
The following code sample implements the approach outlined above:

void TIFFTestDoc::OnFileOpen()
{
CString file_types =
"TIFF Files(*.tiff,*.tif)|*.tif;*.tiff;*.tif;||";

CFileDialog dlg(TRUE,
NULL,
NULL,
OFN_HIDEREADONLY | OFN_EXPLORER,
(LPCTSTR)file_types,NULL);
if (dlg.DoModal() == IDOK)
{
m_filename = dlg.GetPathName();

// 1) Open this puppy up
TIFF * tiff = TIFFOpen((char*)(LPCTSTR)m_filename,"r");
if (tiff)
{

int w=0, h=0;

// 2)
// Get the width and height of the image

TIFFGetField(tiff,TIFFTAG_IMAGEWIDTH, &w);

TIFFGetField(tiff,TIFFTAG_IMAGELENGTH, &h);

if ((w > 0) && (h > 0))
{

// allocate space for the image

uint32 * raster =
(uint32*)GlobalAlloc(GMEM_FIXED,
(w * h * sizeof (uint32)));

if (raster)
{

// creating DIBSection object that encapsulates
// DIB functionality

if (m_dib)
delete m_dib;

m_dib = new DIBSection;

if (m_dib)
{
m_dib->Create(w,h,32);

uint32 dibwidth = m_dib->GetTotalWidth();


// 3)
// copy all the pixel data from the file into
// allocated space

if (TIFFReadRGBAImage(tiff, w, h, raster, 0))
{
// 4)
// its tempting to copy straight to the DIB,
// however the DIB has an alignment
// restriction that is not applicable to
// tiff files...so they may have different
// widths

unsigned long * dest =
(unsigned long *)m_dib->GetBits();

unsigned long * src =
(unsigned long *)raster;

for (int row = 0; row < h; row++){

void * ptr_dest = dest + row * dibwidth;
void * ptr_src = src + row * w;
memcpy(ptr_dest,ptr_src,w*sizeof(int));
}
SetTitle(m_filename);
UpdateAllViews(NULL);
}
}

// 5)
// free the temporary pixel storage space
GlobalFree(raster);
}
}

// 6)
// notify the TIFF library that we are done
// with this puppy
TIFFClose(tiff);
}
}
}
void TIFFTestView::OnDraw(CDC* pDC)
{
TIFFTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

DIBSection * dib = pDoc->GetDIB();

if (pDC->IsPrinting())
{}
else
{
if (dib)
{
CClientDC dc(this);
CPoint sp = GetScrollPosition();
dib->Draw(&dc,sp.x,sp.y);
}
}
}
Additional information about the sample project:

The sample project includes debug and release versions of the TIFF library files that I built, plus header files for the library. This is the minimum required to build the sample project. If you have an interest in working with TIFF files on an ongoing basis I highly recommend that you download the source files and build environment from www.libtiff.org and go through the library build process...it can be painful, but worthwhile in terms of understanding the library.

In 256 color mode the colors may not be correct, but in 16-bit, 24-bit, and 32-bit color mode everything looks fine.

Downloads
Download demo project - 220Kb http://www.codeguru.com/bitmap/tiff_image.zip


回复
Skt32 2003-07-14
http://www.codeproject.com/bitmap/cximage.asp

CxImage
1 May 2003
CxImage is a C++ class to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
回复
soon 2003-07-14
www.libtiff.org 一个c得lib
回复
soon 2003-07-14
tifflib.org
回复
无敌魔仙 2003-07-08
去北大天网http://e.pku.edu.cn检索一下,会有的
回复
peterleex 2003-07-08
找到一个 paintlib 不知道可不可以在 VC7 中使用,看过在说,先谢了.

回复
相关推荐
发帖
图形处理/算法
创建于2007-09-28

1.9w+

社区成员

VC/MFC 图形处理/算法
申请成为版主
帖子事件
创建了帖子
2003-07-08 09:44
社区公告
暂无公告