static void faviconcb(webview * const view) { tab * const cur = findtab(view); if (!cur || cur->state != TS_WEB) return; if (cur->icon) delete cur->icon; cur->icon = wk_get_favicon(cur->url); g->url->url->input().image(NULL); if (!cur->icon) return; // It may be in a wrong resolution - resize in that case if (cur->icon->w() != 16 || cur->icon->h() != 16) { Fl_RGB_Image *old = cur->icon; cur->icon = (Fl_RGB_Image *) old->copy(16, 16); delete old; } if (g->tabs[g->curtab].web == view) { g->url->url->input().image(cur->icon); g->url->redraw(); } g->tabwidget->redraw(); }
/* ============================================================================= =============================================================================== */ 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; }
void TaskButton::update_image_from_xid(void) { E_RETURN_IF_FAIL(xid >= 0); Fl_RGB_Image *img = netwm_window_get_icon(xid, TASKBUTTON_ICON_W); if(!img) return; int width = img->w(), height = img->h(); /* some safety, scale it if needed */ if((width > TASKBUTTON_ICON_W) || (height > TASKBUTTON_ICON_H)) { width = (width > TASKBUTTON_ICON_W) ? TASKBUTTON_ICON_W : width; height = (height > TASKBUTTON_ICON_H) ? TASKBUTTON_ICON_H : height; /* safe casting */ Fl_RGB_Image *scaled = (Fl_RGB_Image*)img->copy(width, height); delete img; img = scaled; } clear_image(); image(img); image_alloc = true; }
GLuint gmshPopplerWrapper::getTextureForPage(double xres, double yres) { int iPage = _currentPage; int numPages = getNumPages(); if(iPage < 0) iPage = 0; if(iPage > numPages - 1) iPage = numPages - 1; std::map<int, GLuint>::iterator it = _pages2textures.find(iPage); if(it != _pages2textures.end()) return it->second; if(!_currentDoc) return 0; poppler::page *page = _currentDoc->create_page(iPage); poppler::page_renderer pr; pr.set_render_hint(poppler::page_renderer::text_antialiasing, true); pr.set_render_hint(poppler::page_renderer::antialiasing, true); poppler::image im = pr.render_page(page, xres, yres, -1, -1, -1); im.save("hop.jpeg", "jpeg"); Fl_RGB_Image *img = new Fl_JPEG_Image("hop.jpeg"); // Fl_RGB_Image *img2 = (Fl_RGB_Image*)img->copy(2048, 2048); glPixelStorei(GL_UNPACK_ROW_LENGTH, img->w()); GLuint texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->w(), img->h(), 0, (img->d() == 4) ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, img->array); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); _w = img->w(); _h = img->h(); delete img; // delete img2; _pages2textures[iPage] = texture; return texture; }