本文整理汇总了C++中Fl_Image::ld方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Image::ld方法的具体用法?C++ Fl_Image::ld怎么用?C++ Fl_Image::ld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Image
的用法示例。
在下文中一共展示了Fl_Image::ld方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Tests Open SLImage
TEST(ImageControllerTest, loadSLImageWithImageController) {
ImageController imageController;
imageController.open(filename);
Fl_Image * image = imageController.getCurrentImage();
ASSERT_NE((void *)NULL, image ) << "File did not open " << filename;
EXPECT_EQ(30, image->w());
EXPECT_EQ(30, image->h());
EXPECT_EQ(3, image->d());
EXPECT_EQ(92, image->ld()); //4 byte aligned under OpenCV not under FLTK
}
示例2: LoadFltkImage
virtual Bitmap *Load(IStream *stream) {
SPADES_MARK_FUNCTION();
// read all
std::string data = stream->ReadAllBytes();
// copy to buffer
Fl_Image *img = LoadFltkImage(data);
SPAssert(img);
SPAssert(img->count() >= 1);
const unsigned char* inPixels =
(const unsigned char *)img->data()[0];
int depth = img->d();
int width = img->w();
int height = img->h();
int pitch = width * depth + img->ld();
Handle<Bitmap> bmp;
try {
bmp = new Bitmap(width, height);
} catch(...) {
delete img;
throw;
}
try {
unsigned char *outPixels = (unsigned char *)bmp->GetPixels();
if(pitch == width * 4 && depth == 4) {
// if the format matches the requirement of Bitmap,
// just use it
memcpy(outPixels, inPixels, pitch * height);
} else {
// convert
const unsigned char* line;
for(int y = 0; y < height; y++) {
line = inPixels;
for(int x = 0; x < width; x++) {
uint8_t r, g, b, a;
switch(depth) {
case 1:
r = g = b = *(line++);
a = 255;
break;
case 2:
r = g = b = *(line++);
a = *(line++);
break;
case 3:
r = *(line++);
g = *(line++);
b = *(line++);
a = 255;
break;
case 4:
r = *(line++);
g = *(line++);
b = *(line++);
a = *(line++);
break;
default:
SPAssert(false);
}
*(outPixels++) = r;
*(outPixels++) = g;
*(outPixels++) = b;
*(outPixels++) = a;
}
inPixels += pitch;
}
}
delete img;
return bmp.Unmanage();
} catch(...) {
delete img;
throw;
}
}