本文整理汇总了C++中FlexImage::setPixelSize方法的典型用法代码示例。如果您正苦于以下问题:C++ FlexImage::setPixelSize方法的具体用法?C++ FlexImage::setPixelSize怎么用?C++ FlexImage::setPixelSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexImage
的用法示例。
在下文中一共展示了FlexImage::setPixelSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testExternal
void testExternal() {
report(0, "testing external image...");
unsigned char buf[EXT_HEIGHT][EXT_WIDTH];
{
for (int x=0; x<EXT_WIDTH; x++) {
for (int y=0; y<EXT_HEIGHT; y++) {
buf[y][x] = 20;
}
}
}
ImageOf<PixelMono> img1;
img1.setExternal(&buf[0][0],EXT_WIDTH,EXT_HEIGHT);
checkEqual(img1.width(),EXT_WIDTH,"width check");
checkEqual(img1.height(),EXT_HEIGHT,"height check");
int mismatch = 0;
for (int x=0; x<img1.width(); x++) {
for (int y=0; y<img1.height(); y++) {
img1.pixel(x,y) = 5;
if (buf[y][x]!=5) {
mismatch++;
}
}
}
checkEqual(mismatch,0,"delta check");
report(0, "testing various padding + alignments...");
for (int ww=1; ww<=17; ww++) {
for (int hh=1; hh<=17; hh++) {
for (int pad1=1; pad1<=9; pad1++) {
for (int pad2=1; pad2<=9; pad2++) {
int wwp1 = (ww%pad1)?(ww+pad1-(ww%pad1)):ww;
FlexImage img;
char *data = new char[wwp1*hh*3];
yAssert(data);
img.setQuantum(pad1);
img.setPixelCode(VOCAB_PIXEL_RGB);
img.setPixelSize(3);
img.setExternal(data,ww,hh);
ImageOf<PixelRgb> target;
target.setQuantum(pad2);
target.copy(img);
delete[] data;
}
}
}
}
}
示例2: copy
bool Image::copy(const Image& alt, int w, int h) {
if (getPixelCode()==0) {
setPixelCode(alt.getPixelCode());
setPixelSize(alt.getPixelSize());
setQuantum(alt.getQuantum());
}
if (&alt==this) {
FlexImage img;
img.copy(alt);
return copy(img,w,h);
}
if (getPixelCode()!=alt.getPixelCode()) {
FlexImage img;
img.setPixelCode(getPixelCode());
img.setPixelSize(getPixelSize());
img.setQuantum(getQuantum());
img.copy(alt);
return copy(img,w,h);
}
resize(w,h);
int d = getPixelSize();
int nw = w;
int nh = h;
w = alt.width();
h = alt.height();
float di = ((float)h)/nh;
float dj = ((float)w)/nw;
for (int i=0; i<nh; i++)
{
int i0 = (int)(di*i);
for (int j=0; j<nw; j++)
{
int j0 = (int)(dj*j);
memcpy(getPixelAddress(j,i),
alt.getPixelAddress(j0,i0),
d);
}
}
return true;
}