ImageGlyph::ImageGlyph(const ImageRGBA& rgba, AlloyContext* context, bool mipmap) : Glyph("image_rgba", GlyphType::Image, 0, 0) { handle = nvgCreateImageRGBA(context->nvgContext, rgba.width, rgba.height, (mipmap) ? NVG_IMAGE_GENERATE_MIPMAPS : 0, rgba.ptr()); width = (pixel) rgba.width; height = (pixel) rgba.height; }
void mergeAlpha(ImageRGBA& im, GnashImage::const_iterator alphaData, const size_t bufferLength) { assert(bufferLength * 4 <= im.size()); // Point to the first alpha byte GnashImage::iterator p = im.begin(); // Premultiplication is also done at rendering time (at least by the // agg renderer). // TODO: use BitmapData.loadBitmap to check whether it's also done here. for (size_t i = 0; i < bufferLength; ++i, ++alphaData) { *p = std::min(*p, *alphaData); ++p; *p = std::min(*p, *alphaData); ++p; *p = std::min(*p, *alphaData); ++p; *p = *alphaData; ++p; } }
void ImageGlyph::set(const ImageRGBA& rgba, AlloyContext* context) { nvgUpdateImage(context->nvgContext, handle, rgba.ptr()); }
void Application::getScreenShot(ImageRGBA& img) { int w = 0, h = 0; glfwGetFramebufferSize(context->window, &w, &h); img.resize(w, h); glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.ptr()); }