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


C++ SetGraphicsMode函数代码示例

本文整理汇总了C++中SetGraphicsMode函数的典型用法代码示例。如果您正苦于以下问题:C++ SetGraphicsMode函数的具体用法?C++ SetGraphicsMode怎么用?C++ SetGraphicsMode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetGraphicsMode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: widget_

	RenderContext::RenderContext(Widget* widget)
		: widget_(widget)
		, gdi_(NULL)
	{
		HDC wnd_dc = BeginPaint(widget->hwnd(), &ps_);
		SetGraphicsMode(wnd_dc, GM_ADVANCED);
		SetMapMode(wnd_dc, MM_TEXT);
		SetBkMode(wnd_dc, OPAQUE);
		//SetBkMode(wnd_dc, TRANSPARENT);

		dc_ = ::CreateCompatibleDC(wnd_dc);
		//dc_ = wnd_dc;
		SetGraphicsMode(dc_, GM_ADVANCED);
		SetMapMode(dc_, MM_TEXT);
		SetBkMode(dc_, OPAQUE);
		//SetMapMode(dc_, MM_LOENGLISH);
		//SetWorldTransform(dc_, &Matrix().ToXFORM());

		RECT rc;
		::GetClientRect(widget->hwnd(), &rc);
		rect_ = rc;

		bitmap_ = CreateDIB(rect_.width(), rect_.height());
		bitmap_prev_ = (HBITMAP)::SelectObject(dc_, bitmap_);
		gdi_ = new Gdiplus::Graphics(dc_);
	}
开发者ID:blueantst,项目名称:DuiFramework,代码行数:26,代码来源:render_context.cpp

示例2: DrawItem

BOOL DrawItem(WPARAM wParam, LPARAM lParam)
{
    LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
    RECT rect = lpdi->rcItem;
    HDC hdc = lpdi->hDC;

    SetGraphicsMode(hdc, GM_ADVANCED);

    switch (wParam)
    {
	// X scale

    case XSCALE_ID:
	return DrawXScale(hdc, rect);
	break;

	// Y scale

    case YSCALE_ID:
	return DrawYScale(hdc, rect);
	break;

	// Scope

    case SCOPE_ID:
	return DrawScope(hdc, rect);
	break;
    }
}
开发者ID:Climberirw,项目名称:audiotools,代码行数:29,代码来源:Scope.c

示例3: floor

//--------------------------------------------------------------
// constructor
FlatWorld::FlatWorld()
{
  m_mapWidth = 0;
  m_mapHeight = 0;

  m_mapDC = NULL;
  m_mapBitmap = NULL;
  m_mapData = NULL;
  m_mapSpan = 0;
  m_mapDepth = 24;

  m_playerX = 0.0;
  m_playerY = 0.0;
  m_playerAngle = 90.0;
  m_terrainScale = 20.0;

  // build initial terrain view
  m_lastTerrainX = (int) floor(m_playerX / m_terrainScale);
  m_lastTerrainY = (int) floor(m_playerY / m_terrainScale);

  m_mapDC = CreateCompatibleDC(NULL);
  SetGraphicsMode(m_mapDC, GM_ADVANCED);

  m_redBrush = CreateSolidBrush(RGB(255, 0, 0));
  m_redPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
}
开发者ID:bond4u,项目名称:SeaOfMemes,代码行数:28,代码来源:FlatWorld.cpp

示例4: CreateCompatibleDC

//--------------------------------------------------------------
// common init
void mgXPSurface::init(
  BOOL singleTile,
  BOOL inworld)
{
  m_singleTile = singleTile;
  m_inworld = inworld;

  // create the DC so we can measure text before setting size
  m_surfaceDC = CreateCompatibleDC(NULL);
  m_alphaDC = CreateCompatibleDC(NULL);
  SetGraphicsMode(m_surfaceDC, GM_ADVANCED);
  SetStretchBltMode(m_surfaceDC, COLORONCOLOR);

  m_logPixelsY = GetDeviceCaps(m_surfaceDC, LOGPIXELSY);

  m_surfaceBitmap = NULL;
  m_alphaBitmap = NULL;
  m_tiles = NULL;
  m_vertTiles = 0;
  m_horzTiles = 0;
  m_isDamaged = false;

  m_imageWidth = 0;
  m_imageHeight = 0;
}
开发者ID:Kelimion,项目名称:SeaOfMemes,代码行数:27,代码来源:mgWinSurface-old.cpp

示例5: cairo_get_target

HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
    // FIXME:  We aren't really doing anything with the 'mayCreateBitmap' flag.  This needs
    // to be addressed.
    if (dstRect.isEmpty())
       return 0;

    // This is probably wrong, and definitely out of date.  Pulled from old SVN
    cairo_surface_t* surface = cairo_get_target(platformContext());
    HDC hdc = cairo_win32_surface_get_dc(surface);   
    SaveDC(hdc);

    // FIXME: We need to make sure a clip is really set on the HDC.
    // Call SetWorldTransform to honor the current Cairo transform.
    SetGraphicsMode(hdc, GM_ADVANCED); // We need this call for themes to honor world transforms.
    cairo_matrix_t mat;
    cairo_get_matrix(platformContext(), &mat);
    XFORM xform;
    xform.eM11 = mat.xx;
    xform.eM12 = mat.xy;
    xform.eM21 = mat.yx;
    xform.eM22 = mat.yy;
    xform.eDx = mat.x0;
    xform.eDy = mat.y0;
    ::SetWorldTransform(hdc, &xform);

    return hdc;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:28,代码来源:GraphicsContextCairoWin.cpp

示例6: Create

// We use this static factory function instead of the regular constructor so
// that we can create the pixel data before calling the constructor. This is
// required so that we can call the base class' constructor with the pixel
// data.
static bool Create(int width, int height, bool is_opaque, SkRasterHandleAllocator::Rec* rec) {
    BITMAPINFOHEADER hdr = { 0 };
    hdr.biSize = sizeof(BITMAPINFOHEADER);
    hdr.biWidth = width;
    hdr.biHeight = -height;  // Minus means top-down bitmap.
    hdr.biPlanes = 1;
    hdr.biBitCount = 32;
    hdr.biCompression = BI_RGB;  // No compression.
    hdr.biSizeImage = 0;
    hdr.biXPelsPerMeter = 1;
    hdr.biYPelsPerMeter = 1;
    void* pixels;
    HBITMAP hbitmap = CreateDIBSection(nullptr, (const BITMAPINFO*)&hdr, 0, &pixels, 0, 0);
    if (!hbitmap) {
        return false;
    }

    size_t row_bytes = width * sizeof(SkPMColor);
    sk_bzero(pixels, row_bytes * height);

    HDC hdc = CreateCompatibleDC(nullptr);
    if (!hdc) {
        DeleteObject(hbitmap);
        return false;
    }
    SetGraphicsMode(hdc, GM_ADVANCED);
    SelectObject(hdc, hbitmap);

    rec->fReleaseProc = DeleteHDCCallback;
    rec->fReleaseCtx = hdc;
    rec->fPixels = pixels;
    rec->fRowBytes = row_bytes;
    rec->fHandle = hdc;
    return true;
}
开发者ID:MIPS,项目名称:external-skia,代码行数:39,代码来源:SampleBigGradient.cpp

示例7: Open

bool
Open()
{
    if (0 <= sFd)
        return true;

    if (!SetGraphicsMode())
        return false;

    ScopedClose fd(open("/dev/graphics/fb0", O_RDWR));
    if (0 > fd.get()) {
        LOG("Error opening framebuffer device");
        return false;
    }

    struct fb_fix_screeninfo fi;
    if (0 > ioctl(fd.get(), FBIOGET_FSCREENINFO, &fi)) {
        LOG("Error getting fixed screeninfo");
        return false;
    }

    if (0 > ioctl(fd.get(), FBIOGET_VSCREENINFO, &sVi)) {
        LOG("Error getting variable screeninfo");
        return false;
    }

    sMappedSize = fi.smem_len;
    void* mem = mmap(0, sMappedSize, PROT_READ | PROT_WRITE, MAP_SHARED,
                     fd.rwget(), 0);
    if (MAP_FAILED == mem) {
        LOG("Error mmap'ing framebuffer");
        return false;
    }

    sFd = fd.get();
    fd.forget();

    // The android porting doc requires a /dev/graphics/fb0 device
    // that's double buffered with r5g6b5 format.  Hence the
    // hard-coded numbers here.
    gfxASurface::gfxImageFormat format = gfxASurface::ImageFormatRGB16_565;
    int bytesPerPixel = gfxASurface::BytePerPixelFromFormat(format);
    if (!sScreenSize) {
        sScreenSize = new gfxIntSize(sVi.xres, sVi.yres);
    }
    long stride = fi.line_length;
    size_t numFrameBytes = stride * sScreenSize->height;

    sBuffers = new BufferVector(2);
    unsigned char* data = static_cast<unsigned char*>(mem);
    for (size_t i = 0; i < 2; ++i, data += numFrameBytes) {
      memset(data, 0, numFrameBytes);
      Buffers()[i] = new gfxImageSurface(data, *sScreenSize, stride, format);
    }

    // Clear the framebuffer to a known state.
    Present(nsIntRect());

    return true;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:60,代码来源:Framebuffer.cpp

示例8: m_hdc

GraphicsContext::WindowsBitmap::WindowsBitmap(HDC hdc, IntSize size)
    : m_hdc(0)
    , m_size(size)
{
    BITMAPINFO bitmapInfo;
    bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bitmapInfo.bmiHeader.biWidth = m_size.width(); 
    bitmapInfo.bmiHeader.biHeight = m_size.height();
    bitmapInfo.bmiHeader.biPlanes = 1;
    bitmapInfo.bmiHeader.biBitCount = 32;
    bitmapInfo.bmiHeader.biCompression = BI_RGB;
    bitmapInfo.bmiHeader.biSizeImage = 0;
    bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
    bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
    bitmapInfo.bmiHeader.biClrUsed = 0;
    bitmapInfo.bmiHeader.biClrImportant = 0;

    m_bitmap = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, reinterpret_cast<void**>(&m_bitmapBuffer), 0, 0);
    if (!m_bitmap)
        return;

    m_hdc = CreateCompatibleDC(hdc);
    SelectObject(m_hdc, m_bitmap);

    BITMAP bmpInfo;
    GetObject(m_bitmap, sizeof(bmpInfo), &bmpInfo);
    m_bytesPerRow = bmpInfo.bmWidthBytes;
    m_bitmapBufferLength = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;

    SetGraphicsMode(m_hdc, GM_ADVANCED);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:31,代码来源:GraphicsContextCGWin.cpp

示例9: CGContextWithHDC

static CGContextRef CGContextWithHDC(HDC hdc, bool hasAlpha)
{
    HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));

    DIBPixelData pixelData(bitmap);

    // FIXME: We can get here because we asked for a bitmap that is too big
    // when we have a tiled layer and we're compositing. In that case 
    // bmBitsPixel will be 0. This seems to be benign, so for now we will
    // exit gracefully and look at it later:
    //  https://bugs.webkit.org/show_bug.cgi?id=52041   
    // ASSERT(bitmapBits.bitsPerPixel() == 32);
    if (pixelData.bitsPerPixel() != 32)
        return 0;

    CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little | (hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst);
    CGContextRef context = CGBitmapContextCreate(pixelData.buffer(), pixelData.size().width(), pixelData.size().height(), 8,
                                                 pixelData.bytesPerRow(), deviceRGBColorSpaceRef(), bitmapInfo);

    // Flip coords
    CGContextTranslateCTM(context, 0, pixelData.size().height());
    CGContextScaleCTM(context, 1, -1);
    
    // Put the HDC In advanced mode so it will honor affine transforms.
    SetGraphicsMode(hdc, GM_ADVANCED);
    
    return context;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:28,代码来源:GraphicsContextCGWin.cpp

示例10: GetDC

void
GDIFontFamily::FindStyleVariations()
{
    if (mHasStyles)
        return;
    mHasStyles = PR_TRUE;

    HDC hdc = GetDC(nsnull);
    SetGraphicsMode(hdc, GM_ADVANCED);

    LOGFONTW logFont;
    memset(&logFont, 0, sizeof(LOGFONTW));
    logFont.lfCharSet = DEFAULT_CHARSET;
    logFont.lfPitchAndFamily = 0;
    PRUint32 l = PR_MIN(mName.Length(), LF_FACESIZE - 1);
    memcpy(logFont.lfFaceName,
           nsPromiseFlatString(mName).get(),
           l * sizeof(PRUnichar));
    logFont.lfFaceName[l] = 0;

    EnumFontFamiliesExW(hdc, &logFont,
                        (FONTENUMPROCW)GDIFontFamily::FamilyAddStylesProc,
                        (LPARAM)this, 0);
#ifdef PR_LOGGING
    if (LOG_FONTLIST_ENABLED() && mAvailableFonts.Length() == 0) {
        LOG_FONTLIST(("(fontlist) no styles available in family \"%s\"",
                      NS_ConvertUTF16toUTF8(mName).get()));
    }
#endif

    ReleaseDC(nsnull, hdc);

    if (mIsBadUnderlineFamily)
        SetBadUnderlineFonts();
}
开发者ID:mmmulani,项目名称:v8monkey,代码行数:35,代码来源:gfxGDIFontList.cpp

示例11: DrawItem

BOOL DrawItem(WPARAM wParam, LPARAM lParam)
{
    LPDRAWITEMSTRUCT lpdi = (LPDRAWITEMSTRUCT)lParam;
    UINT state = lpdi->itemState;
    RECT rect = lpdi->rcItem;
    HDC hdc = lpdi->hDC;

    SetGraphicsMode(hdc, GM_ADVANCED);

    switch (wParam)
    {
	// Spectrum

    case SPECTRUM_ID:
	return DrawSpectrum(hdc, rect);
	break;

	// Display

    case DISPLAY_ID:
	return DrawDisplay(hdc, rect);
	break;

	// Meter

    case METER_ID:
	return DrawMeter(hdc, rect);
	break;
    }
}
开发者ID:Climberirw,项目名称:audiotools,代码行数:30,代码来源:LMS.c

示例12: _cairo_win32_save_initial_clip

static cairo_int_status_t
_cairo_win32_save_initial_clip (HDC hdc, cairo_win32_display_surface_t *surface)
{
    RECT rect;
    int clipBoxType;
    int gm;
    XFORM saved_xform;

    /* GetClipBox/GetClipRgn and friends interact badly with a world transform
     * set.  GetClipBox returns values in logical (transformed) coordinates;
     * it's unclear what GetClipRgn returns, because the region is empty in the
     * case of a SIMPLEREGION clip, but I assume device (untransformed) coordinates.
     * Similarly, IntersectClipRect works in logical units, whereas SelectClipRgn
     * works in device units.
     *
     * So, avoid the whole mess and get rid of the world transform
     * while we store our initial data and when we restore initial coordinates.
     *
     * XXX we may need to modify x/y by the ViewportOrg or WindowOrg
     * here in GM_COMPATIBLE; unclear.
     */
    gm = GetGraphicsMode (hdc);
    if (gm == GM_ADVANCED) {
	GetWorldTransform (hdc, &saved_xform);
	ModifyWorldTransform (hdc, NULL, MWT_IDENTITY);
    }

    clipBoxType = GetClipBox (hdc, &rect);
    if (clipBoxType == ERROR) {
	_cairo_win32_print_gdi_error (__FUNCTION__);
	SetGraphicsMode (hdc, gm);
	/* XXX: Can we make a more reasonable guess at the error cause here? */
	return _cairo_error (CAIRO_STATUS_DEVICE_ERROR);
    }

    surface->win32.extents.x = rect.left;
    surface->win32.extents.y = rect.top;
    surface->win32.extents.width = rect.right - rect.left;
    surface->win32.extents.height = rect.bottom - rect.top;

    surface->initial_clip_rgn = NULL;
    surface->had_simple_clip = FALSE;

    if (clipBoxType == COMPLEXREGION) {
	surface->initial_clip_rgn = CreateRectRgn (0, 0, 0, 0);
	if (GetClipRgn (hdc, surface->initial_clip_rgn) <= 0) {
	    DeleteObject(surface->initial_clip_rgn);
	    surface->initial_clip_rgn = NULL;
	}
    } else if (clipBoxType == SIMPLEREGION) {
	surface->had_simple_clip = TRUE;
    }

    if (gm == GM_ADVANCED)
	SetWorldTransform (hdc, &saved_xform);

    return CAIRO_STATUS_SUCCESS;
}
开发者ID:AlexShiLucky,项目名称:luapower-all,代码行数:58,代码来源:cairo-win32-display-surface.c

示例13: Q_ASSERT

HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
    // painting through native HDC is only supported for plugin, where mayCreateBitmap is always true
    Q_ASSERT(mayCreateBitmap);

    if (dstRect.isEmpty())
        return 0;

    // Create a bitmap DC in which to draw.
    BITMAPINFO bitmapInfo;
    bitmapInfo.bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
    bitmapInfo.bmiHeader.biWidth         = dstRect.width();
    bitmapInfo.bmiHeader.biHeight        = dstRect.height();
    bitmapInfo.bmiHeader.biPlanes        = 1;
    bitmapInfo.bmiHeader.biBitCount      = 32;
    bitmapInfo.bmiHeader.biCompression   = BI_RGB;
    bitmapInfo.bmiHeader.biSizeImage     = 0;
    bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
    bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
    bitmapInfo.bmiHeader.biClrUsed       = 0;
    bitmapInfo.bmiHeader.biClrImportant  = 0;

    void* pixels = 0;
    HBITMAP bitmap = ::CreateDIBSection(NULL, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
    if (!bitmap)
        return 0;

    HDC displayDC = ::GetDC(0);
    HDC bitmapDC = ::CreateCompatibleDC(displayDC);
    ::ReleaseDC(0, displayDC);

    ::SelectObject(bitmapDC, bitmap);

    // Fill our buffer with clear if we're going to alpha blend.
    if (supportAlphaBlend) {
        BITMAP bmpInfo;
        GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
        int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
        memset(bmpInfo.bmBits, 0, bufferSize);
    }

#if !PLATFORM(WIN_CE)
    // Make sure we can do world transforms.
    SetGraphicsMode(bitmapDC, GM_ADVANCED);

    // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
    XFORM xform;
    xform.eM11 = 1.0f;
    xform.eM12 = 0.0f;
    xform.eM21 = 0.0f;
    xform.eM22 = 1.0f;
    xform.eDx = -dstRect.x();
    xform.eDy = -dstRect.y();
    ::SetWorldTransform(bitmapDC, &xform);
#endif

    return bitmapDC;
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:58,代码来源:GraphicsContextQt.cpp

示例14: sizeof

// FIXME: Is it possible to merge getWindowsContext and createWindowsBitmap into a single API
// suitable for all clients?
HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
{
    // FIXME: Should a bitmap be created also when a shadow is set?
    if (mayCreateBitmap && inTransparencyLayer()) {
        if (dstRect.isEmpty())
            return 0;

        // Create a bitmap DC in which to draw.
        BITMAPINFO bitmapInfo;
        bitmapInfo.bmiHeader.biSize          = sizeof(BITMAPINFOHEADER);
        bitmapInfo.bmiHeader.biWidth         = dstRect.width(); 
        bitmapInfo.bmiHeader.biHeight        = dstRect.height();
        bitmapInfo.bmiHeader.biPlanes        = 1;
        bitmapInfo.bmiHeader.biBitCount      = 32;
        bitmapInfo.bmiHeader.biCompression   = BI_RGB;
        bitmapInfo.bmiHeader.biSizeImage     = 0;
        bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
        bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
        bitmapInfo.bmiHeader.biClrUsed       = 0;
        bitmapInfo.bmiHeader.biClrImportant  = 0;

        void* pixels = 0;
        HBITMAP bitmap = ::CreateDIBSection(NULL, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
        if (!bitmap)
            return 0;

        HDC bitmapDC = ::CreateCompatibleDC(m_data->m_hdc);
        ::SelectObject(bitmapDC, bitmap);

        // Fill our buffer with clear if we're going to alpha blend.
        if (supportAlphaBlend) {
            BITMAP bmpInfo;
            GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
            int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
            memset(bmpInfo.bmBits, 0, bufferSize);
        }

        // Make sure we can do world transforms.
        SetGraphicsMode(bitmapDC, GM_ADVANCED);

        // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
        XFORM xform;
        xform.eM11 = 1.0f;
        xform.eM12 = 0.0f;
        xform.eM21 = 0.0f;
        xform.eM22 = 1.0f;
        xform.eDx = -dstRect.x();
        xform.eDy = -dstRect.y();
        ::SetWorldTransform(bitmapDC, &xform);

        return bitmapDC;
    }

    CGContextFlush(platformContext());
    m_data->save();
    return m_data->m_hdc;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:59,代码来源:GraphicsContextCGWin.cpp

示例15: CreateCompatibleDC

//--------------------------------------------------------------
// constructor
BitmapSurface::BitmapSurface()
{
  m_bitmapDC = CreateCompatibleDC(NULL);
  SetGraphicsMode(m_bitmapDC, GM_ADVANCED);

  m_bitmapWidth = 0;
  m_bitmapHeight = 0;
  m_bitmapData = NULL;
  m_bitmap = NULL;
}
开发者ID:bond4u,项目名称:SeaOfMemes,代码行数:12,代码来源:BitmapSurface.cpp


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