Exemple #1
0
/* Various checks along the way.                         */
static void test_ifont_size(LONG lo_size, LONG hi_size,
	LONG ratio_logical, LONG ratio_himetric,
	LONG hfont_height, const char * test_name)
{
	FONTDESC fd;
	LPVOID pvObj = NULL;
	IFont* ifnt = NULL;
	HFONT hfont;
	LOGFONTA lf;
	CY psize;
	HRESULT hres;
        DWORD rtnval;

	fd.cbSizeofstruct = sizeof(FONTDESC);
	fd.lpstrName      = arial_font; /* using scalable instead of bitmap font reduces errors due to font realization */
	S(fd.cySize).Lo   = lo_size;
	S(fd.cySize).Hi   = hi_size;
	fd.sWeight        = 0;
	fd.sCharset       = 0;
        fd.fItalic        = FALSE;
        fd.fUnderline     = FALSE;
        fd.fStrikethrough = FALSE;

	/* Create font, test that it worked. */
	hres = pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj);
	ifnt = pvObj;
	ok(hres == S_OK,"%s: OCFI returns 0x%08x instead of S_OK.\n",
		test_name, hres);
	ok(pvObj != NULL,"%s: OCFI returns NULL.\n", test_name);

        /* Change the scaling ratio */
        hres = IFont_SetRatio(ifnt, ratio_logical, ratio_himetric);
        ok((ratio_logical && ratio_himetric) ? hres == S_OK : hres == E_FAIL,
           "%s: IFont_SetRatio unexpectedly returned 0x%08x.\n", test_name, hres);

	/* Read back size. */
	hres = IFont_get_Size(ifnt, &psize);
	ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n",
		test_name, hres);

        /* Check returned size - allow for errors due to rounding & font realization. */
	ok((abs(S(psize).Lo - lo_size) < 10000) && S(psize).Hi == hi_size,
		"%s: IFont_get_Size: Lo=%d, Hi=%d; expected Lo=%d, Hi=%d.\n",
		test_name, S(psize).Lo, S(psize).Hi, lo_size, hi_size);

	/* Check hFont size. */
	hres = IFont_get_hFont (ifnt, &hfont);
	ok(hres == S_OK, "%s: IFont_get_hFont returns 0x%08x instead of S_OK.\n",
		test_name, hres);
	rtnval = GetObjectA(hfont, sizeof(LOGFONTA), &lf);
        ok(rtnval > 0, "GetObject(hfont) failed\n");

        /* Since font scaling may encounter rounding errors, allow 1 pixel deviation. */
	ok(abs(lf.lfHeight - hfont_height) <= 1,
		"%s: hFont has lf.lfHeight=%d, expected %d.\n",
		test_name, lf.lfHeight, hfont_height);

	/* Free IFont. */
	IFont_Release(ifnt);
}
Exemple #2
0
/**********************************************************************
 *
 *	PSDRV_SetBrush
 *
 */
static BOOL PSDRV_SetBrush( PHYSDEV dev )
{
    PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
    LOGBRUSH logbrush;
    BOOL ret = TRUE;

    if (!GetObjectA( GetCurrentObject(dev->hdc,OBJ_BRUSH), sizeof(logbrush), &logbrush ))
    {
        ERR("Can't get BRUSHOBJ\n");
	return FALSE;
    }

    switch (logbrush.lbStyle) {
    case BS_SOLID:
    case BS_HATCHED:
        PSDRV_WriteSetColor(dev, &physDev->brush.color);
	break;

    case BS_NULL:
        break;

    default:
        ret = FALSE;
        break;

    }
    physDev->brush.set = TRUE;
    return ret;
}
Exemple #3
0
/***********************************************************************
 * Initializes the cards.dll library. Loads the card bitmaps from the
 * resources, and initializes the card size variables.
 */
BOOL WINAPI cdtInit(int *width, int *height)
{
	BITMAP bm;
	int i;

	TRACE("(%p, %p)\n", width, height);

	for(i = 0; i <= CARD_MAX; i++)
		cardBitmaps[i] = 0;

	for(i = 0; i <= CARD_MAX; i++)
	{
		cardBitmaps[i] = LoadBitmapA(hInst, MAKEINTRESOURCEA(i));
		if(cardBitmaps[i] == 0)
		{
			cdtTerm();
			return FALSE;
		}
	}

	GetObjectA(cardBitmaps[0], sizeof(BITMAP), &bm);
	*width = cardWidth = bm.bmWidth;
	*height = cardHeight = bm.bmHeight;
	return TRUE;
}
Exemple #4
0
/***********************************************************************
 *           SetDeskWallPaper   (USER32.@)
 *
 * FIXME: is there a unicode version?
 */
BOOL WINAPI SetDeskWallPaper( LPCSTR filename )
{
    HBITMAP hbitmap;
    HDC hdc;
    char buffer[256];

    if (filename == (LPSTR)-1)
    {
	GetProfileStringA( "desktop", "WallPaper", "(None)", buffer, 256 );
	filename = buffer;
    }
    hdc = GetDC( 0 );
    hbitmap = DESKTOP_LoadBitmap( hdc, filename );
    ReleaseDC( 0, hdc );
    if (hbitmapWallPaper) DeleteObject( hbitmapWallPaper );
    hbitmapWallPaper = hbitmap;
    fTileWallPaper = GetProfileIntA( "desktop", "TileWallPaper", 0 );
    if (hbitmap)
    {
	BITMAP bmp;
	GetObjectA( hbitmap, sizeof(bmp), &bmp );
	bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1;
	bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1;
    }
    return TRUE;
}
Exemple #5
0
/***********************************************************************
 *           MFDRV_SelectPalette
 */
HPALETTE MFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPalette, BOOL bForceBackground )
{
#define PALVERSION 0x0300

    PLOGPALETTE logPalette;
    WORD        wNumEntries = 0;
    BOOL        creationSucceed;
    int         sizeofPalette;

    GetObjectA(hPalette, sizeof(WORD), &wNumEntries);

    if (wNumEntries == 0) return 0;

    sizeofPalette = sizeof(LOGPALETTE) + ((wNumEntries-1) * sizeof(PALETTEENTRY));
    logPalette = HeapAlloc( GetProcessHeap(), 0, sizeofPalette );

    if (logPalette == NULL) return 0;

    logPalette->palVersion = PALVERSION;
    logPalette->palNumEntries = wNumEntries;

    GetPaletteEntries(hPalette, 0, wNumEntries, logPalette->palPalEntry);

    creationSucceed = MFDRV_CreatePalette( dev, hPalette, logPalette, sizeofPalette );

    HeapFree( GetProcessHeap(), 0, logPalette );

    if (creationSucceed)
        return hPalette;

    return 0;
}
Exemple #6
0
void
Test_Pen(void)
{
    LOGPEN logpen;
    HPEN hPen;

    FillMemory(&logpen, sizeof(LOGPEN), 0x77);
    hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6));
    ok(hPen != 0, "CreatePen failed, skipping tests.\n");
    if (!hPen) return;
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n");
    ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n");
    ok(GetObject(hPen, 0, &logpen) == 0, "\n");
    ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n");
    //ok(GetLastError() == ERROR_SUCCESS, "\n"); fails on win7

    /* test if the fields are filled correctly */
    ok(logpen.lopnStyle == PS_SOLID, "\n");

    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, sizeof(LOGPEN), &logpen) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());

    DeleteObject(hPen);
}
Exemple #7
0
static DWORD WINAPI thread_proc(void *param)
{
    LOGPEN lp;
    DWORD status;
    struct hgdiobj_event *hgdiobj_event = param;

    hgdiobj_event->hdc = CreateDCA("display", NULL, NULL, NULL);
    ok(hgdiobj_event->hdc != NULL, "CreateDC error %u\n", GetLastError());

    hgdiobj_event->hgdiobj1 = CreatePen(PS_DASHDOTDOT, 17, RGB(1, 2, 3));
    ok(hgdiobj_event->hgdiobj1 != 0, "Failed to create pen\n");

    hgdiobj_event->hgdiobj2 = CreateRectRgn(0, 1, 12, 17);
    ok(hgdiobj_event->hgdiobj2 != 0, "Failed to create pen\n");

    SetEvent(hgdiobj_event->ready_event);
    status = WaitForSingleObject(hgdiobj_event->stop_event, INFINITE);
    ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());

    ok(!GetObjectA(hgdiobj_event->hgdiobj1, sizeof(lp), &lp), "GetObject should fail\n");

    ok(!GetDeviceCaps(hgdiobj_event->hdc, TECHNOLOGY), "GetDeviceCaps(TECHNOLOGY) should fail\n");

    return 0;
}
    bool setFont(const char * pFontName = NULL, int nSize = 0)
    {
        bool bRet = false;
        do 
        {
            HFONT       hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            LOGFONTA    tNewFont = {0};
            LOGFONTA    tOldFont = {0};
            GetObjectA(hDefFont, sizeof(tNewFont), &tNewFont);
            if (pFontName)
            {
                strcpy_s(tNewFont.lfFaceName, LF_FACESIZE, pFontName);
            }
            if (nSize)
            {
                tNewFont.lfHeight = -nSize;
            }
            GetObjectA(m_hFont,  sizeof(tOldFont), &tOldFont);

            if (tOldFont.lfHeight == tNewFont.lfHeight
                && ! strcpy(tOldFont.lfFaceName, tNewFont.lfFaceName))
            {
                // already has the font 
                bRet = true;
                break;
            }

            // delete old font
            if (m_hFont != hDefFont)
            {
                DeleteObject(m_hFont);
            }
            m_hFont = NULL;

            // create new font
            m_hFont = CreateFontIndirectA(&tNewFont);
            if (! m_hFont)
            {
                // create failed, use default font
                m_hFont = hDefFont;
                break;
            }
            
            bRet = true;
        } while (0);
        return bRet;
    }
Exemple #9
0
static bool MCTextLayoutFontFromHFONT(void *p_font, MCTextLayoutFont*& r_font)
{
	bool t_success;
	t_success = true;

	// First fetch the HFONT's LOGFONT structure
	LOGFONTA t_logfont;
	if (t_success)
		if (!GetObjectA(p_font, sizeof(LOGFONTA), &t_logfont))
			t_success = false;

	if (t_success)
		t_logfont . lfHeight = -256;

	// Now use this to search for an existing layout font
	MCTextLayoutFont *self;
	self = nil;
	if (t_success)
	{
		self = MCTextLayoutFontFind(t_logfont);
		if (self != nil)
		{
			r_font = self;
			return true;
		}
	}

	// Otherwise we must go ahead and create a new font
	if (t_success)
		t_success = MCMemoryNew(self);

	if (t_success)
	{
		self -> handle = CreateFontIndirectA(&t_logfont);
		if (self -> handle == nil)
			t_success = false;
	}

	if (t_success)
	{
		MCListPushFront(s_fonts, self);
		self -> info = t_logfont;

		// Now see if the font is a linked font
		for(MCTextLayoutLinkedFont *t_links = s_linked_fonts; t_links != nil; t_links = t_links -> next)
			if (MCCStringEqualCaseless(t_links -> name, self -> info . lfFaceName))
			{
				self -> linking = t_links;
				break;
			}

		r_font = self;
	}
	else
		MCTextLayoutFontDestroy(self);
	
	return t_success;
}
Exemple #10
0
/***********************************************************************
 *           ICONTITLE_Paint
 */
static BOOL ICONTITLE_Paint( HWND hwnd, HWND owner, HDC hDC, BOOL bActive )
{
    RECT rect;
    HFONT hPrevFont;
    HBRUSH hBrush;
    COLORREF textColor = 0;

    if( bActive )
    {
	hBrush = GetSysColorBrush(COLOR_ACTIVECAPTION);
	textColor = GetSysColor(COLOR_CAPTIONTEXT);
    }
    else
    {
        if( GetWindowLongPtrA( hwnd, GWL_STYLE ) & WS_CHILD )
	{
	    hBrush = (HBRUSH) GetClassLongPtrW(hwnd, GCLP_HBRBACKGROUND);
	    if( hBrush )
	    {
		INT level;
		LOGBRUSH logBrush;
		GetObjectA( hBrush, sizeof(logBrush), &logBrush );
		level = GetRValue(logBrush.lbColor) +
			   GetGValue(logBrush.lbColor) +
			      GetBValue(logBrush.lbColor);
		if( level < (0x7F * 3) )
		    textColor = RGB( 0xFF, 0xFF, 0xFF );
	    }
	    else
		hBrush = GetStockObject( WHITE_BRUSH );
	}
	else
	{
	    hBrush = GetStockObject( BLACK_BRUSH );
	    textColor = RGB( 0xFF, 0xFF, 0xFF );
	}
    }

    GetClientRect( hwnd, &rect );
    DPtoLP( hDC, (LPPOINT)&rect, 2 );
    FillRect( hDC, &rect, hBrush );

    hPrevFont = SelectObject( hDC, hIconTitleFont );
    if( hPrevFont )
    {
	WCHAR buffer[80];

        INT length = GetWindowTextW( owner, buffer, sizeof(buffer)/sizeof(buffer[0]) );
        SetTextColor( hDC, textColor );
        SetBkMode( hDC, TRANSPARENT );

        DrawTextW( hDC, buffer, length, &rect, DT_CENTER | DT_NOPREFIX |
                   DT_WORDBREAK | ((bMultiLineTitle) ? 0 : DT_SINGLELINE) );

	SelectObject( hDC, hPrevFont );
    }
    return (hPrevFont != 0);
}
Exemple #11
0
void MCStack::device_updatewindow(MCRegionRef p_region)
{
	if (m_window_shape == nil || m_window_shape -> is_sharp)
	{
		InvalidateRgn((HWND)window -> handle . window, (HRGN)p_region, FALSE);
		UpdateWindow((HWND)window -> handle . window);
	}
	else
	{
		MCRectangle t_device_rect;
		t_device_rect = MCGRectangleGetIntegerBounds(MCResUserToDeviceRect(MCRectangleMake(0, 0, m_window_shape->width, m_window_shape->height)));

		HBITMAP t_bitmap = nil;
		void *t_bits = nil;

		if (m_window_shape -> handle == nil)
		{
			if (!create_temporary_dib(((MCScreenDC*)MCscreen)->getdsthdc(), t_device_rect.width, t_device_rect.height, t_bitmap, t_bits))
				return;

			m_window_shape -> handle = t_bitmap;
		}
		else
		{
			t_bitmap = (HBITMAP)m_window_shape -> handle;

			BITMAP t_bitmap_struct;
			GetObjectA(t_bitmap, sizeof(BITMAP), &t_bitmap_struct);
			t_bits = t_bitmap_struct.bmBits;
		}

		MCGRaster t_raster;
		t_raster.width = t_device_rect.width;
		t_raster.height = t_device_rect.height;
		t_raster.pixels = t_bits;
		t_raster.stride = t_raster.width * sizeof(uint32_t);
		t_raster.format = kMCGRasterFormat_ARGB;

		MCGRaster t_mask;
		/* UNCHECKED */ MCWin32GetWindowShapeAlphaMask(m_window_shape, t_mask);

		MCWindowsLayeredStackSurface t_surface(t_raster, &t_mask);

		if (t_surface.Lock())
		{
			if (s_update_callback == nil)
				device_redrawwindow(&t_surface, (MCRegionRef)p_region);
			else
				s_update_callback(&t_surface, (MCRegionRef)p_region, s_update_context);

			t_surface.Unlock();

			composite();
		}
	}
}
Exemple #12
0
void
Test_MetaDC(void)
{
    /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */
    HDC hMetaDC;
    BYTE buffer[1000];

    hMetaDC = CreateMetaFile(NULL);
    ok(hMetaDC != 0, "CreateMetaFile failed, skipping tests.\n");
    if(!hMetaDC) return;

    ok(((UINT_PTR)hMetaDC & GDI_HANDLE_TYPE_MASK) == GDI_OBJECT_TYPE_METADC, "\n");

    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0, "\n");
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0, "\n");
    ok(GetObjectA(hMetaDC, 0, NULL) == 0, "\n");
    ok(GetObjectA(hMetaDC, 1000, &buffer) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
}
Exemple #13
0
/***********************************************************************
 *           SelectBrush   (X11DRV.@)
 */
HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush )
{
    X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
    LOGBRUSH logbrush;

    if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;

    TRACE("hdc=%p hbrush=%p\n", dev->hdc, hbrush);

    if (physDev->brush.pixmap)
    {
        wine_tsx11_lock();
        XFreePixmap( gdi_display, physDev->brush.pixmap );
        wine_tsx11_unlock();
        physDev->brush.pixmap = 0;
    }
    physDev->brush.style = logbrush.lbStyle;
    if (hbrush == GetStockObject( DC_BRUSH ))
        logbrush.lbColor = GetDCBrushColor( dev->hdc );

    switch(logbrush.lbStyle)
    {
      case BS_NULL:
	TRACE("BS_NULL\n" );
	break;

      case BS_SOLID:
        TRACE("BS_SOLID\n" );
	BRUSH_SelectSolidBrush( physDev, logbrush.lbColor );
	break;

      case BS_HATCHED:
	TRACE("BS_HATCHED\n" );
	physDev->brush.pixel = X11DRV_PALETTE_ToPhysical( physDev, logbrush.lbColor );
        wine_tsx11_lock();
        physDev->brush.pixmap = XCreateBitmapFromData( gdi_display, root_window,
                                                       HatchBrushes[logbrush.lbHatch], 8, 8 );
        wine_tsx11_unlock();
	physDev->brush.fillStyle = FillStippled;
	break;

      case BS_PATTERN:
	TRACE("BS_PATTERN\n");
	if (!BRUSH_SelectPatternBrush( physDev, (HBITMAP)logbrush.lbHatch )) return 0;
	break;

      case BS_DIBPATTERN:
	TRACE("BS_DIBPATTERN\n");
	if (!BRUSH_SelectDIBPatternBrush( physDev, (HGLOBAL)logbrush.lbHatch )) return 0;
	break;
    }
    return hbrush;
}
Exemple #14
0
void
Test_Colorspace(void)
{
    UCHAR buffer[1000];

    SetLastError(ERROR_SUCCESS);
    GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL);
    //ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? fails on win7
    ok_err(ERROR_INSUFFICIENT_BUFFER);
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0, "\n");
    ok_err(ERROR_INSUFFICIENT_BUFFER);
    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 327, buffer) == 0, "\n");
    ok_err(ERROR_INSUFFICIENT_BUFFER);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, buffer) == 0, "\n");
    ok_err(ERROR_INVALID_PARAMETER);

    //ok_long(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, NULL), 0); // FIXME: fails on WHS
    //ok_err(ERROR_INSUFFICIENT_BUFFER);
}
Exemple #15
0
static void test_thread_objects(void)
{
    LOGPEN lp;
    DWORD tid, type;
    HANDLE hthread;
    struct hgdiobj_event hgdiobj_event;
    INT ret;
    DWORD status;
    BOOL bRet;

    hgdiobj_event.stop_event = CreateEventA(NULL, 0, 0, NULL);
    ok(hgdiobj_event.stop_event != NULL, "CreateEvent error %u\n", GetLastError());
    hgdiobj_event.ready_event = CreateEventA(NULL, 0, 0, NULL);
    ok(hgdiobj_event.ready_event != NULL, "CreateEvent error %u\n", GetLastError());

    hthread = CreateThread(NULL, 0, thread_proc, &hgdiobj_event, 0, &tid);
    ok(hthread != NULL, "CreateThread error %u\n", GetLastError());

    status = WaitForSingleObject(hgdiobj_event.ready_event, INFINITE);
    ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());

    ret = GetObjectA(hgdiobj_event.hgdiobj1, sizeof(lp), &lp);
    ok(ret == sizeof(lp), "GetObject error %u\n", GetLastError());
    ok(lp.lopnStyle == PS_DASHDOTDOT, "wrong pen style %d\n", lp.lopnStyle);
    ok(lp.lopnWidth.x == 17, "wrong pen width.y %d\n", lp.lopnWidth.x);
    ok(lp.lopnWidth.y == 0, "wrong pen width.y %d\n", lp.lopnWidth.y);
    ok(lp.lopnColor == RGB(1, 2, 3), "wrong pen width.y %08x\n", lp.lopnColor);

    ret = GetDeviceCaps(hgdiobj_event.hdc, TECHNOLOGY);
    ok(ret == DT_RASDISPLAY, "GetDeviceCaps(TECHNOLOGY) should return DT_RASDISPLAY not %d\n", ret);

    bRet = DeleteObject(hgdiobj_event.hgdiobj1);
    ok(bRet, "DeleteObject error %u\n", GetLastError());
    bRet = DeleteDC(hgdiobj_event.hdc);
    ok(bRet, "DeleteDC error %u\n", GetLastError());

    type = GetObjectType(hgdiobj_event.hgdiobj2);
    ok(type == OBJ_REGION, "GetObjectType returned %u\n", type);

    SetEvent(hgdiobj_event.stop_event);
    status = WaitForSingleObject(hthread, INFINITE);
    ok(status == WAIT_OBJECT_0, "WaitForSingleObject error %u\n", GetLastError());
    CloseHandle(hthread);

    type = GetObjectType(hgdiobj_event.hgdiobj2);
    ok(type == OBJ_REGION, "GetObjectType returned %u\n", type);
    bRet = DeleteObject(hgdiobj_event.hgdiobj2);
    ok(bRet, "DeleteObject error %u\n", GetLastError());

    CloseHandle(hgdiobj_event.stop_event);
    CloseHandle(hgdiobj_event.ready_event);
}
Exemple #16
0
void
Test_Palette(void)
{
    LOGPALETTE logpal;
    HPALETTE hPalette;
    WORD wPalette;

    FillMemory(&wPalette, sizeof(WORD), 0x77);
    logpal.palVersion = 0x0300;
    logpal.palNumEntries = 1;
    logpal.palPalEntry[0].peRed = 0;
    logpal.palPalEntry[0].peGreen = 0;
    logpal.palPalEntry[0].peBlue = 0;
    logpal.palPalEntry[0].peFlags = PC_EXPLICIT;
    hPalette = CreatePalette(&logpal);
    ok(hPalette != 0, "CreatePalette failed, skipping tests.\n");
    if (!hPalette) return;

    ok(GetObjectA((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");
    ok(GetObjectW((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");

    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
    ok(GetObject(hPalette, sizeof(WORD), NULL) == sizeof(WORD), "\n");
    ok(GetObject(hPalette, 0, NULL) == sizeof(WORD), "\n");
    ok(GetObject(hPalette, 5, NULL) == sizeof(WORD), "\n");
    ok(GetObject(hPalette, -5, NULL) == sizeof(WORD), "\n");
    ok(GetObject(hPalette, sizeof(WORD), &wPalette) == sizeof(WORD), "\n");
    ok(GetObject(hPalette, sizeof(WORD)+2, &wPalette) == sizeof(WORD), "\n");
    ok(GetObject(hPalette, 0, &wPalette) == 0, "\n");
    ok(GetObject(hPalette, 1, &wPalette) == 0, "\n");
    ok(GetObject(hPalette, -1, &wPalette) == sizeof(WORD), "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");
    DeleteObject(hPalette);
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, sizeof(WORD), &wPalette) == 0, "\n");
    ok(GetLastError() == ERROR_SUCCESS, "\n");

}
Exemple #17
0
/***********************************************************************
 *           init_wallpaper
 */
static void init_wallpaper( const WCHAR *wallpaper )
{
    HBITMAP hbitmap = DESKTOP_LoadBitmap( wallpaper );

    if (hbitmapWallPaper) DeleteObject( hbitmapWallPaper );
    hbitmapWallPaper = hbitmap;
    if (hbitmap)
    {
	BITMAP bmp;
	GetObjectA( hbitmap, sizeof(bmp), &bmp );
	bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1;
	bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1;
        fTileWallPaper = GetProfileIntA( "desktop", "TileWallPaper", 0 );
    }
}
Exemple #18
0
/******************************************************************
 *         EMFDRV_CreatePenIndirect
 */
static HPEN EMFDRV_CreatePenIndirect(DC *dc, HPEN hPen )
{
    EMRCREATEPEN emr;
    DWORD index = 0;

    if (!GetObjectA( hPen, sizeof(emr.lopn), &emr.lopn )) return 0;

    emr.emr.iType = EMR_CREATEPEN;
    emr.emr.nSize = sizeof(emr);
    emr.ihPen = index = EMFDRV_AddHandleDC( dc );

    if(!EMFDRV_WriteRecord( dc, &emr.emr ))
        index = 0;
    return index;
}
Exemple #19
0
void GetBitmapInfo(BITMAPINFO &rBmpinfo, HBITMAP compatibleHbitmap)
{
    BITMAP bitmap = { 0 };
    GetObjectA(compatibleHbitmap, sizeof(bitmap), &bitmap);

    rBmpinfo.bmiHeader.biBitCount = bitmap.bmBitsPixel;//颜色位数
    rBmpinfo.bmiHeader.biClrImportant = 0;
    rBmpinfo.bmiHeader.biCompression = BI_RGB;
    rBmpinfo.bmiHeader.biHeight = bitmap.bmHeight;
    rBmpinfo.bmiHeader.biPlanes = bitmap.bmPlanes; //级别?必须为1
    rBmpinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    rBmpinfo.bmiHeader.biSizeImage = bitmap.bmHeight*bitmap.bmWidth*bitmap.bmBitsPixel;
    rBmpinfo.bmiHeader.biWidth = bitmap.bmWidth;
    rBmpinfo.bmiHeader.biXPelsPerMeter = 0;
    rBmpinfo.bmiHeader.biYPelsPerMeter = 0;
}
Exemple #20
0
void
Test_CreateFontIndirectExW(void)
{
    ENUMLOGFONTEXDVW elfedv, elfedv2;
    ENUMLOGFONTEXDVA elfedva;
    ENUMLOGFONTEXW *penumlfw;
    LOGFONTW *plogfontw;
    HFONT hFont;
    ULONG ret;
 
    memset(&elfedv, 0, sizeof(elfedv));
    penumlfw = &elfedv.elfEnumLogfontEx;
    plogfontw = &elfedv.elfEnumLogfontEx.elfLogFont;

    plogfontw->lfHeight = 12;
    plogfontw->lfWidth = 0;
    plogfontw->lfEscapement = 0;
    plogfontw->lfOrientation = 0;
    plogfontw->lfWeight = FW_NORMAL;
    plogfontw->lfItalic = 0;
    plogfontw->lfUnderline = 0;
    plogfontw->lfStrikeOut = 0;
    plogfontw->lfCharSet = DEFAULT_CHARSET;
    plogfontw->lfOutPrecision = OUT_DEFAULT_PRECIS;
    plogfontw->lfClipPrecision = CLIP_DEFAULT_PRECIS;
    plogfontw->lfQuality = PROOF_QUALITY;
    plogfontw->lfPitchAndFamily = DEFAULT_PITCH;

    memset(plogfontw->lfFaceName, 'A', LF_FACESIZE * sizeof(WCHAR));
    memset(penumlfw->elfFullName, 'B', LF_FULLFACESIZE * sizeof(WCHAR));

    hFont = CreateFontIndirectExW(&elfedv);
    ok(hFont != 0, "CreateFontIndirectExW failed\n");

    memset(&elfedv2, 0, sizeof(elfedv2));
    ret = GetObjectW(hFont, sizeof(elfedv2), &elfedv2);
    ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n");
    ok(elfedv2.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == ((WCHAR)'A' << 8) + 'A', "\n");
    ok(elfedv2.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == ((WCHAR)'B' << 8) + 'B', "\n");

    memset(&elfedva, 0, sizeof(elfedva));
    ret = GetObjectA(hFont, sizeof(elfedva), &elfedva);
    ok(ret == sizeof(ENUMLOGFONTEXDVA), "\n");
    ok(elfedva.elfEnumLogfontEx.elfLogFont.lfFaceName[LF_FACESIZE-1] == '?', "\n");
    ok(elfedva.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0, "\n");
}
Exemple #21
0
HBITMAP
WINAPI
CreateCompatibleBitmap(
    HDC hDC,
    INT Width,
    INT Height)
{
    PDC_ATTR pDc_Attr;

    if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID) & pDc_Attr))
        return NULL;

    if (!Width || !Height)
        return GetStockObject(DEFAULT_BITMAP);

    if (!(pDc_Attr->ulDirty_ & DC_DIBSECTION))
    {
        return NtGdiCreateCompatibleBitmap(hDC, Width, Height);
    }
    else
    {
        HBITMAP hBmp = NULL;
        struct
        {
            BITMAP bitmap;
            BITMAPINFOHEADER bmih;
            RGBQUAD rgbquad[256];
        } buffer;
        DIBSECTION* pDIBs = (DIBSECTION*) &buffer;
        BITMAPINFO* pbmi = (BITMAPINFO*) &buffer.bmih;

        hBmp = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_BITMAP);

        if (GetObjectA(hBmp, sizeof(DIBSECTION), pDIBs) != sizeof(DIBSECTION))
            return NULL;

        if (pDIBs->dsBm.bmBitsPixel <= 8)
            GetDIBColorTable(hDC, 0, 256, buffer.rgbquad);

        pDIBs->dsBmih.biWidth = Width;
        pDIBs->dsBmih.biHeight = Height;

        return CreateDIBSection(hDC, pbmi, DIB_RGB_COLORS, NULL, NULL, 0);
    }
    return NULL;
}
Exemple #22
0
static void PopulateImageList(HIMAGELIST *iList, HWND list)
{
    struct gphoto2_file *file;
    HWND 	progress_dialog;

    progress_dialog =
        CreateDialogW(GPHOTO2_instance,(LPWSTR)MAKEINTRESOURCE(IDD_CONNECTING),
                      NULL, ConnectingProc);

    LIST_FOR_EACH_ENTRY( file, &activeDS.files, struct gphoto2_file, entry)
    {
        if (strstr(file->filename,".JPG") || strstr(file->filename,".jpg"))
        {
            HBITMAP 	bitmap;
            BITMAP		bmpInfo;

#ifdef HAVE_GPHOTO2
            _get_gphoto2_file_as_DIB(file->folder, file->filename,
                                     GP_FILE_TYPE_PREVIEW, 0, &bitmap);
#else
            bitmap = 0;
#endif
            GetObjectA(bitmap,sizeof(BITMAP),&bmpInfo);

            if (*iList == 0)
            {
                *iList = ImageList_Create(bmpInfo.bmWidth,
                                          bmpInfo.bmHeight,ILC_COLOR24, 10,10);

                SendMessageW(list, LVM_SETICONSPACING, 0,
                             MAKELONG(bmpInfo.bmWidth+6, bmpInfo.bmHeight+15) );
            }

            ImageList_Add(*iList, bitmap, 0);

            DeleteObject(static_bitmap);
            static_bitmap = bitmap;
            SendMessageW(GetDlgItem(progress_dialog,IDC_BITMAP),STM_SETIMAGE,
                         IMAGE_BITMAP, (LPARAM)static_bitmap);
            RedrawWindow(progress_dialog,NULL,NULL,RDW_INTERNALPAINT|RDW_UPDATENOW|RDW_ALLCHILDREN);
        }
    }
    EndDialog(progress_dialog,0);

}
Exemple #23
0
void Test_CreateFontA()
{
	HFONT hFont;
	LOGFONTA logfonta;
	INT result;

	/* Test invalid font name */
	hFont = CreateFontA(15, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
	                    DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
	                    DEFAULT_QUALITY, DEFAULT_PITCH, INVALIDFONT);
	ok(hFont != 0, "CreateFontA failed\n");

	result = GetObjectA(hFont, sizeof(LOGFONTA), &logfonta);
	ok(result == sizeof(LOGFONTA), "result = %d", result);

	ok(memcmp(logfonta.lfFaceName, INVALIDFONT, strlen(INVALIDFONT)) == 0, "not equal\n");
	ok(logfonta.lfWeight == FW_DONTCARE, "lfWeight=%ld\n", logfonta.lfWeight);

}
Exemple #24
0
void
Test_Dibsection(void)
{
    BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
    HBITMAP hBitmap;
    BITMAP bitmap;
    DIBSECTION dibsection;
    PVOID pData;
    HDC hDC;

    FillMemory(&dibsection, sizeof(DIBSECTION), 0x77);
    hDC = GetDC(0);
    hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0);
    ok(hBitmap != 0, "CreateDIBSection failed with %ld, skipping tests.\n", GetLastError());
    if (!hBitmap) return;

    ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
    ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");

    SetLastError(ERROR_SUCCESS);
    ok_long(GetObject(hBitmap, sizeof(DIBSECTION), NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, 0, NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, 5, NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, -5, NULL), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, 0, &dibsection), 0);
    ok_long(GetObject(hBitmap, 5, &dibsection), 0);
    ok_long(GetObject(hBitmap, sizeof(BITMAP), &bitmap), sizeof(BITMAP));
    ok_long(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap), sizeof(BITMAP));
    ok_long(bitmap.bmType, 0);
    ok_long(bitmap.bmWidth, 10);
    ok_long(bitmap.bmHeight, 9);
    ok_long(bitmap.bmWidthBytes, 20);
    ok_long(bitmap.bmPlanes, 1);
    ok_long(bitmap.bmBitsPixel, 16);
    ok(bitmap.bmBits == pData, "\n");
    ok_long(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION));
    ok_long(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection), sizeof(DIBSECTION));
    ok_long(GetObject(hBitmap, -5, &dibsection), sizeof(DIBSECTION));
    ok_err(ERROR_SUCCESS);
    DeleteObject(hBitmap);
    ReleaseDC(0, hDC);
}
Exemple #25
0
void
Test_Brush(void)
{
    LOGBRUSH logbrush;
    HBRUSH hBrush;

    FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
    hBrush = CreateSolidBrush(RGB(1,2,3));
    ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
    if (!hBrush) return;

    SetLastError(ERROR_SUCCESS);
    ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, sizeof(WORD), NULL) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, 0, NULL) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, 5, NULL) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, -5, NULL) == sizeof(LOGBRUSH), "\n");

    //ok(GetObject(hBrush, 0, &logbrush) == 0, "\n"); fails on win7
    ok(logbrush.lbStyle == 0x77777777, "\n");
    ok(GetObject(hBrush, 5, &logbrush) == sizeof(LOGBRUSH), "\n");
    ok(logbrush.lbStyle == 0, "\n");
    ok(logbrush.lbColor == 0x77777701, "\n");

    ok(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, sizeof(LOGBRUSH) - 1, &logbrush) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, 1, &logbrush) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, sizeof(LOGBRUSH)+2, &logbrush) == sizeof(LOGBRUSH), "\n");
    ok(GetObject(hBrush, -1, &logbrush) == sizeof(LOGBRUSH), "\n");
    // TODO: test all members

    ok(GetLastError() == ERROR_SUCCESS, "\n");
    DeleteObject(hBrush);

    ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, sizeof(LOGBRUSH), &logbrush) == 0, "\n");
    ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
}
Exemple #26
0
/***********************************************************************
 *           SelectBrush   (WINEPS.@)
 */
HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
                          const BITMAPINFO *info, void *bits, UINT usage )
{
    PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
    LOGBRUSH logbrush;

    if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;

    TRACE("hbrush = %p\n", hbrush);

    if (hbrush == GetStockObject( DC_BRUSH ))
        logbrush.lbColor = GetDCBrushColor( dev->hdc );

    switch(logbrush.lbStyle) {

    case BS_SOLID:
        PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
	break;

    case BS_NULL:
        break;

    case BS_HATCHED:
        PSDRV_CreateColor(dev, &physDev->brush.color, logbrush.lbColor);
        break;

    case BS_PATTERN:
    case BS_DIBPATTERN:
	break;

    default:
        FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
	break;
    }

    physDev->brush.set = FALSE;
    return hbrush;
}
Exemple #27
0
bool copyFromBitmap(HDC dc,bmpImage &image,HBITMAP m_tmpBitmap)
{
    bool res = false;
    if (m_tmpBitmap!=0)
    {
        int Success;
        BITMAP bm;
        // Get informations about the bitmap
        if (GetObjectA(m_tmpBitmap, sizeof(BITMAP), (char *)&bm))
        {            
            // Create the image
            image.create( (unsigned int)bm.bmWidth, 
                (unsigned int )bm.bmHeight,bm.bmBitsPixel,0);
                // The GetDIBits function clears the biClrUsed and biClrImportant BITMAPINFO members (dont't know why) 
                // So we save these infos below. This is needed for palettized images only. 
                int nColors = image.getColorsUsed();
                // Copy the pixels
                Success = GetDIBits(dc,								// handle to DC
                    m_tmpBitmap,						// handle to bitmap
                    0,							// first scan line to set
                    image.getHeight(),	// number of scan lines to copy
                    image.getBits(),	// array for bitmap bits
                    image.getInfo(),	// bitmap data buffer
                    0				    // RGB 
                    );
                LPBITMAPINFOHEADER m_Infobm = image.getInfoHeader();
                if (m_Infobm)
                {
                    m_Infobm->biClrUsed = nColors;
                    m_Infobm->biClrImportant = nColors;
                }            
            res = (Success != 0);
        }
    }
    return res;
}
Exemple #28
0
/***********************************************************************
 *           SelectBrush   (WINEPS.@)
 */
HBRUSH CDECL PSDRV_SelectBrush( PSDRV_PDEVICE *physDev, HBRUSH hbrush )
{
    LOGBRUSH logbrush;

    if (!GetObjectA( hbrush, sizeof(logbrush), &logbrush )) return 0;

    TRACE("hbrush = %p\n", hbrush);

    if (hbrush == GetStockObject( DC_BRUSH ))
        logbrush.lbColor = GetDCBrushColor( physDev->hdc );

    switch(logbrush.lbStyle) {

    case BS_SOLID:
        PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
	break;

    case BS_NULL:
        break;

    case BS_HATCHED:
        PSDRV_CreateColor(physDev, &physDev->brush.color, logbrush.lbColor);
        break;

    case BS_PATTERN:
    case BS_DIBPATTERN:
	break;

    default:
        FIXME("Unrecognized brush style %d\n", logbrush.lbStyle);
	break;
    }

    physDev->brush.set = FALSE;
    return hbrush;
}
Exemple #29
0
    \warning This function is only available on Windows.

    \sa toWinHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}

*/
QPixmap QPixmap::fromWinHBITMAP(HBITMAP bitmap, HBitmapFormat format)
{
    // Verify size
    BITMAP bitmap_info;
    memset(&bitmap_info, 0, sizeof(BITMAP));

    int res;
    QT_WA({
            res = GetObjectW(bitmap, sizeof(BITMAP), &bitmap_info);
        } , {
              res = GetObjectA(bitmap, sizeof(BITMAP), &bitmap_info);
          });

    if (!res) {
        qErrnoWarning("QPixmap::fromWinHBITMAP(), failed to get bitmap info");
        return QPixmap();
    }
    int w = bitmap_info.bmWidth;
    int h = bitmap_info.bmHeight;

    BITMAPINFO bmi;
    memset(&bmi, 0, sizeof(bmi));
    bmi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth       = w;
    bmi.bmiHeader.biHeight      = -h;
    bmi.bmiHeader.biPlanes      = 1;
Exemple #30
0
INT16 MFDRV_CreateBrushIndirect(PHYSDEV dev, HBRUSH hBrush )
{
    DWORD size;
    METARECORD *mr;
    LOGBRUSH logbrush;
    BOOL r;

    if (!GetObjectA( hBrush, sizeof(logbrush), &logbrush )) return -1;

    switch(logbrush.lbStyle)
    {
    case BS_SOLID:
    case BS_NULL:
    case BS_HATCHED:
        {
	    LOGBRUSH16 lb16;

	    lb16.lbStyle = logbrush.lbStyle;
	    lb16.lbColor = logbrush.lbColor;
	    lb16.lbHatch = logbrush.lbHatch;
	    size = sizeof(METARECORD) + sizeof(LOGBRUSH16) - 2;
	    mr = HeapAlloc( GetProcessHeap(), 0, size );
	    mr->rdSize = size / 2;
	    mr->rdFunction = META_CREATEBRUSHINDIRECT;
	    memcpy( mr->rdParm, &lb16, sizeof(LOGBRUSH16));
	    break;
	}
    case BS_PATTERN:
        {
            char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
            BITMAPINFO *dst_info, *src_info = (BITMAPINFO *)buffer;
            struct gdi_image_bits bits;
	    COLORREF cref;

            if (!get_bitmap_image( (HANDLE)logbrush.lbHatch, src_info, &bits )) goto done;
	    if (src_info->bmiHeader.biBitCount != 1)
            {
	        FIXME("Trying to store a colour pattern brush\n");
                if (bits.free) bits.free( &bits );
		goto done;
	    }

	    size = FIELD_OFFSET( METARECORD, rdParm[2] ) +
                FIELD_OFFSET( BITMAPINFO, bmiColors[2] ) + src_info->bmiHeader.biSizeImage;

            if (!(mr = HeapAlloc( GetProcessHeap(), 0, size )))
            {
                if (bits.free) bits.free( &bits );
                goto done;
            }
	    mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
	    mr->rdSize = size / 2;
	    mr->rdParm[0] = BS_PATTERN;
	    mr->rdParm[1] = DIB_RGB_COLORS;
            dst_info = (BITMAPINFO *)(mr->rdParm + 2);
            dst_info->bmiHeader = src_info->bmiHeader;
            dst_info->bmiHeader.biClrUsed = 0;
	    cref = GetTextColor( dev->hdc );
            dst_info->bmiColors[0].rgbRed = GetRValue(cref);
            dst_info->bmiColors[0].rgbGreen = GetGValue(cref);
            dst_info->bmiColors[0].rgbBlue = GetBValue(cref);
            dst_info->bmiColors[0].rgbReserved = 0;
	    cref = GetBkColor( dev->hdc );
            dst_info->bmiColors[1].rgbRed = GetRValue(cref);
            dst_info->bmiColors[1].rgbGreen = GetGValue(cref);
            dst_info->bmiColors[1].rgbBlue = GetBValue(cref);
            dst_info->bmiColors[1].rgbReserved = 0;

            /* always return a bottom-up DIB */
            if (dst_info->bmiHeader.biHeight < 0)
            {
                int i, width_bytes = get_dib_stride( dst_info->bmiHeader.biWidth,
                                                     dst_info->bmiHeader.biBitCount );
                char *dst_ptr = (char *)&dst_info->bmiColors[2];
                dst_info->bmiHeader.biHeight = -dst_info->bmiHeader.biHeight;
                dst_ptr += (dst_info->bmiHeader.biHeight - 1) * width_bytes;
                for (i = 0; i < dst_info->bmiHeader.biHeight; i++, dst_ptr -= width_bytes)
                    memcpy( dst_ptr, (char *)bits.ptr + i * width_bytes, width_bytes );
            }
            else memcpy( &dst_info->bmiColors[2], bits.ptr, dst_info->bmiHeader.biSizeImage );
            if (bits.free) bits.free( &bits );
	    break;
	}

    case BS_DIBPATTERN:
        {
	      BITMAPINFO *info;
	      DWORD bmSize, biSize;

	      info = GlobalLock( (HGLOBAL)logbrush.lbHatch );
	      if (info->bmiHeader.biCompression)
		  bmSize = info->bmiHeader.biSizeImage;
	      else
		  bmSize = get_dib_image_size( info );
	      biSize = bitmap_info_size(info, LOWORD(logbrush.lbColor));
	      size = sizeof(METARECORD) + biSize + bmSize + 2;
	      mr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
              if (!mr)
              {
                  GlobalUnlock( (HGLOBAL)logbrush.lbHatch );
                  goto done;
              }
	      mr->rdFunction = META_DIBCREATEPATTERNBRUSH;
	      mr->rdSize = size / 2;
	      *(mr->rdParm) = logbrush.lbStyle;
	      *(mr->rdParm + 1) = LOWORD(logbrush.lbColor);
	      memcpy(mr->rdParm + 2, info, biSize + bmSize);
              GlobalUnlock( (HGLOBAL)logbrush.lbHatch );
	      break;
	}
	default:
	    FIXME("Unkonwn brush style %x\n", logbrush.lbStyle);
	    return 0;
    }
    r = MFDRV_WriteRecord( dev, mr, mr->rdSize * 2);
    HeapFree(GetProcessHeap(), 0, mr);
    if( !r )
        return -1;
done:
    return MFDRV_AddHandle( dev, hBrush );
}