当前位置: 首页>>代码示例>>C++>>正文


C++ Fl_Image::d方法代码示例

本文整理汇总了C++中Fl_Image::d方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Image::d方法的具体用法?C++ Fl_Image::d怎么用?C++ Fl_Image::d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fl_Image的用法示例。


在下文中一共展示了Fl_Image::d方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
开发者ID:sanyaade-g2g-repos,项目名称:shapelogic-cpp,代码行数:11,代码来源:ImageControllerTest.cpp

示例2: openTextureFile

/* =============================================================================
 =============================================================================== */
int C3DSceneMgr::createUITexture(string strFileName, int &width, int &height, int &txWidth)
{
	Fl_Image * img = openTextureFile(strFileName);
	if (img == NULL) {
		return -1;
	}

	width = img->w();
	height = img->h();

	//  need to add an alpha channel to properly overlay on existing textures
	const unsigned char *pData = NULL;
	if (img->d() == 3)
		pData = makeRGBA((const unsigned char *) img->data()[0], width, height);
	else
		pData = (const unsigned char *) img->data()[0];

	GLuint	textureID;
	glGenTextures(1, &textureID);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	glBindTexture(GL_TEXTURE_2D, textureID);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

	int txHeight = height;
	txWidth = (width <= 64) ? 64 : (width <= 128) ? 128 : width;

	const unsigned char *pDataNew = NULL;
	if (width != txWidth)
	{
		pDataNew = padOut(pData, width, height, txWidth);
		txHeight = txWidth;
	}

	glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); 
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, txWidth, txHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pDataNew ? pDataNew : pData);

	if (pDataNew) delete[] pDataNew;
	if (img->d() == 3) delete[] pData;
	delete img;

	return textureID;
}
开发者ID:ribells,项目名称:cove_yurt,代码行数:45,代码来源:scene_tex.cpp

示例3: createTextureDDS

/* =============================================================================
 =============================================================================== */
int C3DSceneMgr::createTexture(string strFileName, int &width, int &height, int iTxMode)
{
	if (strFileName == "") //  Return from the function if no file name was passed in
		return -1;
	if (!fileexists(strFileName))
		return -1;

	//  Load the image and store the data
	int textureID = -1;
	if (getExt(strFileName) == ".dds")
	{
		DDS_IMAGE_DATA	*pDDSImageData = NULL;
		if ((pDDSImageData = loadDDSTextureFile(strFileName)) != NULL)
		{
			textureID = createTextureDDS(pDDSImageData);
			height = pDDSImageData->sizeY;
			width = pDDSImageData->sizeX;
		}
		else	//  case where worldwind wraps jpegs in dds files
		{
			Fl_RGB_Image *img = new Fl_JPEG_Image(strFileName.c_str());
			if (img->d() == 0)
				return -1;
			width = img->w();
			height = img->h();
			const unsigned char *pData = (const unsigned char *) img->data()[0];
			textureID = createTexture(pData, width, height, GL_RGB, GL_RGB, iTxMode);
			delete img;
		}
	}
	else
	{
		Fl_Image * img = openTextureFile(strFileName);
		if (img == NULL)
			return -1;
		width = img->w();
		height = img->h();
		const unsigned char *pData = (const unsigned char *) img->data()[0];
		textureID = createTexture(pData, width, height, img->d() == 4 ? GL_RGBA : GL_RGB, GL_RGBA, iTxMode);
		delete img;
	}

	return textureID;
}
开发者ID:ribells,项目名称:cove_yurt,代码行数:46,代码来源:scene_tex.cpp

示例4: if

//=============================================================================
Fl_Image * openTextureFile(string strFileName)
{
	Fl_Image *img = NULL;
	try
	{
		if (getExt(strFileName) == ".jpg" || getExt(strFileName) == ".jpeg")
			img = new Fl_JPEG_Image(strFileName.c_str());
		else if (getExt(strFileName) == ".png")
			img = new Fl_PNG_Image(strFileName.c_str());
		else
			img = new Fl_BMP_Image(strFileName.c_str());
	}
	catch(std::bad_alloc x)
	{
		mem_alloc_failure(__FILE__, __LINE__);
		return NULL;
	}

	//  return if no image
	if (img->d() == 0 || img->h() == 0 || img->w() == 0)
	{
		delete img;
		return NULL;
	}

	//  downsize if image is too big
	if (img->h() > 4096 || img->w() > 4096)
	{
		cout << ("Downsizing image to maximum of 4096 a side");
		int h = img->h() >= img->w() ? 4096 : 4096 * img->h() / img->w();
		int w = img->w() >= img->h() ? 4096 : 4096 * img->w() / img->h();
		Fl_Image *img2 = img->copy(w, h);
		delete img;
		img = img2;
	}
	
	return img;
}
开发者ID:ribells,项目名称:cove_yurt,代码行数:39,代码来源:scene_tex.cpp

示例5: 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;
        }
    }
开发者ID:harrisonpartch,项目名称:openspades,代码行数:79,代码来源:FltkImageReader.cpp


注:本文中的Fl_Image::d方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。