⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wzpixmaptest.html

📁 有限元学习研究用源代码(老外的),供科研人员参考
💻 HTML
字号:
<TITLE>wzpixmap.hxx - test example</TITLE>
<H1>Test Example for Pixmaps</H1>
<PRE>
#include "wzpixmap.hxx"
</PRE>

<H2>class wzTrueColorPixmap</H2>

The class <B>wzTrueColorPixmap</B> should be able to read true color
pictures in many formats.  At the current time, it allows to read only
the simplest pixmap format - <B>PPM</B>. Thus, you have to transfer
pictures in other formats into PPM. I use <B>xv</B> for this purpose.

<PRE>
void test()
{
 wzTrueColorPixmap tmap("test/colors.ppm");
 tmap.save("test/wzpixmaptest1.ppm"); // compare if they are identical
</PRE>

<H2>class wzColorTablePixmap</H2>

ls This class has a color table and indices into this color table.  The
maximal length of the color table is 256.  With lower number of
<B>maxcolors</B> the algorithm to identify similar colors in a true
color picture becomes faster. Instead of creating a
<B>wzColorTablePixmap</B> explicit from a <B>wzTrueColorPixmap</B> by

<PRE>
 int maxcolors=20;
 wzColorTablePixmap map(tmap,maxcolors);
 map.save("test/wzpixmaptest2.ppm"); // compare if they are identical
</PRE>

you can immediately create it from a file, in this case the true color
pixmap is allocated only temporary

<PRE>
// wzColorTablePixmap map("pixmap.ppm",maxcolors);
</PRE>

How to use the resulting color table can be seen here:

<PRE>
 cout	<< "Pixmap [" << map.lx() << ","<< map.ly()<<"] with "
	<< map.colors() << " colors\n";
 for(int i=1;i<=map.colors();i++){
	cout 	<< i << ": "<< map.color(i) << "\n";
 }
</PRE>

A loop over the whole picture has to be organized in this way:

<PRE>
// int ix,iy,index;
// wzColor color;
// for(ix=0;ix<map.lx();ix++){
//	for(iy=0;iy<map.ly();iy++){
//		index = map(ix,iy);
//		color = map.color(index);
//	}
// }

}
</PRE>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -