void QAhiScreen::solidFill(const QColor &color, const QRegion ®) { AhiSts_t status = AhiStsOk; switch (pixelFormat()) { case QImage::Format_ARGB32_Premultiplied: case QImage::Format_ARGB32: case QImage::Format_RGB32: status = AhiDrawBrushFgColorSet(d_ptr->context, color.rgba()); break; case QImage::Format_RGB16: status = AhiDrawBrushFgColorSet(d_ptr->context, qt_convRgbTo16(color.rgb())); break; default: qFatal("QAhiScreen::solidFill(): Not implemented for pixel format %d", int(pixelFormat())); break; } if (status != AhiStsOk) { qWarning("QAhiScreen::solidFill(): AhiDrawBrushFgColorSet failed: %x", status); return; } status = AhiDrawBrushSet(d_ptr->context, 0, 0, 0, AHIFLAG_BRUSHSOLID); if (status != AhiStsOk) { qWarning("QAhiScreen::solidFill(): AhiDrawBrushSet failed: %x", status); return; } status = AhiDrawRopSet(d_ptr->context, AHIMAKEROP3(AHIROPPATCOPY)); if (status != AhiStsOk) { qWarning("QAhiScreen::solidFill(): AhiDrawRopSet failed: %x", status); return; } status = AhiDrawSurfDstSet(d_ptr->context, d_ptr->surface, 0); if (status != AhiStsOk) { qWarning("QAhiScreen::solidFill(): AhiDrawSurfDst failed: %x", status); return; } const QVector<QRect> rects = (reg & region()).rects(); QVarLengthArray<AhiRect_t> ahiRects(rects.size()); for (int i = 0; i < rects.size(); ++i) { const QRect rect = rects.at(i); ahiRects[i].left = rect.left(); ahiRects[i].top = rect.top(); ahiRects[i].right = rect.x() + rect.width(); ahiRects[i].bottom = rect.y() + rect.height(); } status = AhiDrawBitBltMulti(d_ptr->context, ahiRects.data(), 0, ahiRects.size()); if (status != AhiStsOk) qWarning("QAhiScreen::solidFill(): AhiDrawBitBlt failed: %x", status); }
bool ensureImage(int w, int h) { if (ximage && ximage->width == w && ximage->height == h) return true; warn_bad_pitch = true; destroyX11Image(); use_shm = XShmQueryExtension(display); qDebug("use x11 shm: %d", use_shm); if (!use_shm) goto no_shm; // data seems not aligned ximage = XShmCreateImage(display, vinfo.visual, depth, ZPixmap, NULL, &shm, w, h); if (!ximage) { qWarning("XShmCreateImage error"); goto no_shm; } shm.shmid = shmget(IPC_PRIVATE, ximage->bytes_per_line*ximage->height, IPC_CREAT | 0777); if (shm.shmid < 0) { qWarning("shmget error"); goto no_shm; } shm.shmaddr = (char *)shmat(shm.shmid, 0, 0); if (shm.shmaddr == (char*)-1) { if (!ximage_data.isEmpty()) ximage->data = NULL; XDestroyImage(ximage); ximage = NULL; ximage_data.clear(); qWarning("Shared memory error,disabling ( seg id error )"); goto no_shm; } ximage->data = shm.shmaddr; shm.readOnly = False; if (!XShmAttach(display, &shm)) { qWarning("Attach to shm failed! try to use none shm"); goto no_shm; } XSync(display, False); shmctl(shm.shmid, IPC_RMID, 0); pixfmt = pixelFormat(ximage); return true; no_shm: ximage = XCreateImage(display, vinfo.visual, depth, ZPixmap, 0, NULL, w, h, 8, 0); if (!ximage) return false; pixfmt = pixelFormat(ximage); ximage->data = NULL; XSync(display, False); // TODO: align 16 or? ximage_data.resize(ximage->bytes_per_line*ximage->height + 32); return true; }
osg::Image* textImage() { #ifdef OSGAGG_USE_FREETYPE unsigned char* buffer = new unsigned char[640 * 480 * 4]; agg::rendering_buffer renderingBuf( buffer, 640, 480, 640*4 ); agg::pixfmt_rgba32 pixelFormat( renderingBuf ); agg::renderer_base<agg::pixfmt_rgba32> renderer( pixelFormat ); renderer.clear( agg::rgba8(0, 0, 0, 0) ); agg::renderer_scanline_bin_solid< agg::renderer_base<agg::pixfmt_rgba32> > solidBin( renderer ); solidBin.color( agg::rgba8(255, 255, 255, 255) ); agg::font_engine_freetype_int32 font; agg::font_cache_manager<agg::font_engine_freetype_int32> fontManager(font); if ( font.load_font("arial.ttf", 0, agg::glyph_ren_native_mono) ) { font.hinting( true ); font.height( 64 ); font.width( 64 ); font.flip_y( true ); agg::trans_affine transformation; transformation *= agg::trans_affine_rotation( agg::deg2rad(-4.0) ); font.transform( transformation ); double x = 30.0, y = 450.0; const char* text = "Hello World!"; const char* ptr = text; while ( *ptr ) { const agg::glyph_cache* glyph = fontManager.glyph( *ptr ); if ( glyph ) { fontManager.add_kerning( &x, &y ); fontManager.init_embedded_adaptors( glyph, x, y ); switch ( glyph->data_type ) { case agg::glyph_data_mono: agg::render_scanlines( fontManager.mono_adaptor(), fontManager.mono_scanline(), solidBin ); break; default: break; } x += glyph->advance_x; y += glyph->advance_y; } ptr++; } } osg::ref_ptr<osg::Image> image = new osg::Image; image->setImage( 640, 480, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, buffer, osg::Image::USE_NEW_DELETE ); return image.release(); #else OSG_NOTICE << "[osgagg] FreeType support not built" << std::endl; return new osg::Image; #endif }
status_t LayerBitmap::getInfo(surface_info_t* info) const { if (mSurface.data == 0) { memset(info, 0, sizeof(surface_info_t)); info->bits_offset = NO_MEMORY; return NO_MEMORY; } info->w = uint16_t(width()); info->h = uint16_t(height()); info->stride= uint16_t(stride()); info->bpr = uint16_t(stride() * bytesPerPixel(pixelFormat())); info->format= uint8_t(pixelFormat()); info->flags = surface_info_t::eBufferDirty; info->bits_offset = ssize_t(mOffset); return NO_ERROR; }
//! [5] void SvgalibScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion ®) { if (depth() == 8) { switch (img.format()) { case QImage::Format_RGB16: blit16To8(img, topLeft, reg); return; case QImage::Format_RGB32: case QImage::Format_ARGB32: case QImage::Format_ARGB32_Premultiplied: blit32To8(img, topLeft, reg); return; default: break; } } if (img.format() != pixelFormat()) { if (base()) QScreen::blit(img, topLeft, reg); return; } const QVector<QRect> rects = (reg & region()).rects(); for (int i = 0; i < rects.size(); ++i) { const QRect r = rects.at(i); gl_putboxpart(r.x(), r.y(), r.width(), r.height(), img.width(), img.height(), static_cast<void*>(const_cast<uchar*>(img.bits())), r.x() - topLeft.x(), r.y() - topLeft.y()); } }
STDMETHODIMP UIFrameBuffer::COMGETTER(PixelFormat) (ULONG *puPixelFormat) { if (!puPixelFormat) return E_POINTER; *puPixelFormat = pixelFormat(); return S_OK; }
astra_status_t device_stream<TFrameWrapper>::on_open() { if (is_open()) return astra_status_t::ASTRA_STATUS_SUCCESS; LOG_INFO("orbbec.mocks.device_stream", "creating mock stream of type: %d", description().type()); LOG_INFO("orbbec.mocks.device_stream", "created mock stream of type: %d", description().type()); LOG_INFO("orbbec.mocks.device_stream", "stream type %d supports modes:", description().type()); for(auto it = deviceStream_->modes_begin(); it != deviceStream_->modes_end(); ++it) { auto mode = *it; LOG_INFO("orbbec.mocks.device_stream", "mode: %ux%ux%u@%u pf:%u", mode.width(), mode.height(), mode.bytesPerPixel(), mode.fps(), mode.pixelFormat()); } set_mode(deviceStream_->active_mode()); return astra_status_t::ASTRA_STATUS_SUCCESS; }
void DirectDraw::setDisplayMode(int width, int height, int bpp, int refreshRate) { debugC(ERROR_BASIC, kDebugGraphics, "DirectDraw::SetDisplayMode (%d x %d), %d bpp", width, height, bpp); assert(bpp == 16); Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); initGraphics(width, height, true, &pixelFormat); }
void QAhiScreen::blit(const QImage &image, const QPoint &topLeft, const QRegion ®) { AhiPixelFormat_t pixFmt = pixelFormatForImageFormat(image.format()); if (pixFmt >= AhiPixelFormatMax) { // generic fallback QImage::Format toFormat = pixelFormat(); if (toFormat == QImage::Format_Invalid) toFormat = QImage::Format_ARGB32; blit(image.convertToFormat(toFormat), topLeft, reg); return; } AhiSts_t status; status = AhiDrawSurfDstSet(d_ptr->context, d_ptr->surface, 0); if (status != AhiStsOk) { qWarning("QAhiScreen::blit(): AhiDrawSurfDstSet failed: %x", status); return; } const QVector<QRect> rects = (reg & region()).rects(); const int numRects = rects.size(); QVarLengthArray<AhiPoint_t, 8> src(numRects); QVarLengthArray<AhiRect_t, 8> dest(numRects); for (int i = 0; i < numRects; ++i) { const QRect rect = rects.at(i); src[i].x = rect.x() - topLeft.x(); src[i].y = rect.y() - topLeft.y(); dest[i].left = rect.left(); dest[i].top = rect.top(); dest[i].right = rect.x() + rect.width(); dest[i].bottom = rect.y() + rect.height(); } AhiSize_t bitmapSize = { image.width(), image.height() }; AhiBitmap_t bitmap = { bitmapSize, (void*)(image.bits()), image.bytesPerLine(), pixFmt }; status = AhiDrawRopSet(d_ptr->context, AHIMAKEROP3(AHIROPSRCCOPY)); if (status != AhiStsOk) { qWarning("QAhiScreen::blit(): AhiDrawRopSet failed: %x", status); return; } for (int i = 0; i < numRects; ++i) { status = AhiDrawBitmapBlt(d_ptr->context, &dest[i], &src[i], &bitmap, 0, 0); if (status != AhiStsOk) { qWarning("QAhiScreen::blit(): AhiDrawBitmapBlt failed: %x", status); break; } } }
/** * Initializes the graphics window */ void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); _bGrabScreenshot = false; _bGrabThumbnail = false; _bGrabMovie = false; _wiping = false; }
//! [0] bool DBScreen::initDevice() { if (!QLinuxFbScreen::initDevice()) return false; QScreenCursor::initSoftwareCursor(); image = new QImage(deviceWidth(), deviceHeight(), pixelFormat()); painter = new QPainter(image); return true; }
osg::Image* gradientImage() { unsigned char* buffer = new unsigned char[640 * 480 * 3]; agg::rendering_buffer renderingBuf( buffer, 640, 480, 640*3 ); agg::pixfmt_rgb24 pixelFormat( renderingBuf ); agg::renderer_base<agg::pixfmt_rgb24> renderer( pixelFormat ); renderer.clear( agg::rgba8(150, 150, 150) ); agg::rgba8 span[640]; for ( unsigned int i=0; i<640; ++i ) { agg::rgba c(380.0 + 400.0 * (float)i / 640.0, 0.8); span[i] = agg::rgba8(c); } for ( unsigned int i=0; i<480; ++i ) { renderer.blend_color_hspan( 0, i, 640, span, NULL ); } osg::ref_ptr<osg::Image> image = new osg::Image; image->setImage( 640, 480, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, buffer, osg::Image::USE_NEW_DELETE ); return image.release(); }
void DuokanScreen::blit(const QImage& image, const QPoint& topLeft, const QRegion& region) { QImage imageInverted = image; //if (!isKindle5 && !isKindleTouch) // imageInverted.invertPixels(); #ifdef DEBUG_OUTPUT if (debugMode) qDebug(">>>>%s%s blit image %dx%dx%d type=%d", (isKindle4)? "K4":"", (isKindle5)? "K5":"",image.width(),image.height(), image.depth() ,image.format()) ; #endif //if ((isKindle4) || (isKindle5)) //{ // blit_K4( imageInverted, topLeft, region); //} //else { QScreen::blit(imageInverted, topLeft, region); } QImage trans_image((const uchar*)(base()), dw, dh, pixelFormat()); trans_image.save("/mnt/us/DK_System/duokan/d.png", "png"); }
void DuokanScreen::blit12To4(const QImage &image, const QPoint &topLeft, const QRegion ®ion) { image.save("/mnt/us/DK_System/duokan/b.png", "png"); const int imageStride = image.bytesPerLine() / 2; const QVector<QRect> rects = region.rects(); int scolor ; for (int i = 0; i < rects.size(); ++i) { const QRect r = rects.at(i).translated(-topLeft); int y = r.y(); const quint16 *s = reinterpret_cast<const quint16*>(image.scanLine(y)); while (y <= r.bottom()) { int x1 = r.x(); while (x1 <= r.right()) { const quint16 c = s[x1]; int x2 = x1; // find span length while ((x2+1 < r.right()) && (s[x2+1] == c)) ++x2; scolor = alloc((c>>8) & 0x0f, (c>>4) & 0x0f, c & 0x0f) ; k4_hline(x1 + topLeft.x(), y + topLeft.y(), x2 + topLeft.x(), scolor); x1 = x2 + 1; } s += imageStride; ++y; } } QImage trans_image((const uchar*)(base()), dw, dh, pixelFormat()); trans_image.save("/mnt/us/DK_System/duokan/c.png", "png"); }
bool BitmapData::loadGrimBm(Common::SeekableReadStream *data) { uint32 tag2 = data->readUint32BE(); if (tag2 != (MKTAG('F','\0','\0','\0'))) return false; int codec = data->readUint32LE(); data->readUint32LE(); //_paletteIncluded _numImages = data->readUint32LE(); _x = data->readUint32LE(); _y = data->readUint32LE(); data->readUint32LE(); //_transparentColor _format = data->readUint32LE(); _bpp = data->readUint32LE(); // uint32 redBits = data->readUint32LE(); // uint32 greenBits = data->readUint32LE(); // uint32 blueBits = data->readUint32LE(); // uint32 redShift = data->readUint32LE(); // uint32 greenShift = data->readUint32LE(); // uint32 blueShift = data->readUint32LE(); // Hardcode the format, since the values saved in the files are garbage for some, like "ha_0_elvos.zbm". Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); data->seek(128, SEEK_SET); _width = data->readUint32LE(); _height = data->readUint32LE(); _colorFormat = BM_RGB565; _hasTransparency = false; _data = new Graphics::PixelBuffer[_numImages]; data->seek(0x80, SEEK_SET); for (int i = 0; i < _numImages; i++) { data->seek(8, SEEK_CUR); _data[i].create(pixelFormat, _width * _height, DisposeAfterUse::YES); if (codec == 0) { uint32 dsize = _bpp / 8 * _width * _height; data->read(_data[i].getRawBuffer(), dsize); } else if (codec == 3) { int compressed_len = data->readUint32LE(); char *compressed = new char[compressed_len]; data->read(compressed, compressed_len); bool success = decompress_codec3(compressed, (char *)_data[i].getRawBuffer(), _bpp / 8 * _width * _height); delete[] compressed; if (!success) warning(".. when loading image %s.\n", _fname.c_str()); } else Debug::error(Debug::Bitmaps, "Unknown image codec in BitmapData ctor!"); #ifdef SCUMM_BIG_ENDIAN if (_format == 1) { uint16 *d = (uint16 *)_data[i].getRawBuffer(); for (int j = 0; j < _width * _height; ++j) { d[j] = SWAP_BYTES_16(d[j]); } } #endif } // Initially, no GPU-side textures created. the createBitmap // function will allocate some if necessary (and successful) _numTex = 0; _texIds = nullptr; g_driver->createBitmap(this); return true; }
void QQnxWindow::setBufferSize(const QSize &size) { qWindowDebug() << Q_FUNC_INFO << "window =" << window() << "size =" << size; // libscreen fails when creating empty buffers const QSize nonEmptySize = size.isEmpty() ? QSize(1, 1) : size; int format = pixelFormat(); if (nonEmptySize == m_bufferSize || format == -1) return; Q_SCREEN_CRITICALERROR( screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, &format), "Failed to set window format"); if (m_bufferSize.isValid()) { // destroy buffers first, if resized Q_SCREEN_CRITICALERROR(screen_destroy_window_buffers(m_window), "Failed to destroy window buffers"); } int val[2] = { nonEmptySize.width(), nonEmptySize.height() }; Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val), "Failed to set window buffer size"); Q_SCREEN_CRITICALERROR(screen_create_window_buffers(m_window, MAX_BUFFER_COUNT), "Failed to create window buffers"); // check if there are any buffers available int bufferCount = 0; Q_SCREEN_CRITICALERROR( screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount), "Failed to query render buffer count"); if (bufferCount != MAX_BUFFER_COUNT) { qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d.", MAX_BUFFER_COUNT, bufferCount); } // Set the transparency. According to QNX technical support, setting the window // transparency property should always be done *after* creating the window // buffers in order to guarantee the property is paid attention to. if (window()->requestedFormat().alphaBufferSize() == 0) { // To avoid overhead in the composition manager, disable blending // when the underlying window buffer doesn't have an alpha channel. val[0] = SCREEN_TRANSPARENCY_NONE; } else { // Normal alpha blending. This doesn't commit us to translucency; the // normal backfill during the painting will contain a fully opaque // alpha channel unless the user explicitly intervenes to make something // transparent. val[0] = SCREEN_TRANSPARENCY_SOURCE_OVER; } Q_SCREEN_CHECKERROR(screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val), "Failed to set window transparency"); // Cache new buffer size m_bufferSize = nonEmptySize; resetBuffers(); }
status_t LayerBitmap::resize(uint32_t w, uint32_t h) { int err = setBits(w, h, mAlignment, pixelFormat(), SECURE_BITS); return err; }
void DirectDrawSurface::create(int w, int h) { Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); _surface = new Graphics::ManagedSurface(w, h, pixelFormat); _disposeAfterUse = DisposeAfterUse::YES; }
std::string pixelFormatString( ) const { return pixelFormat_toString( pixelFormat() ); }