ReactOS 0.4.15-dev-8241-g63935f8
TextTransform.c File Reference
#include "precomp.h"
Include dependency graph for TextTransform.c:

Go to the source code of this file.

Classes

struct  tagBITMAPINFOEX
 
struct  TEST_ENTRY
 

Macros

#define WIDTH   200
 
#define HEIGHT   200
 
#define XCENTER   (WIDTH / 2)
 
#define YCENTER   (HEIGHT / 2)
 
#define BLACK   RGB(0, 0, 0)
 
#define WHITE   RGB(255, 255, 255)
 
#define LFHEIGHT   -50
 
#define LFWIDTH1   100
 
#define LFESCAPE1   (-90 * 10)
 
#define POS(ix, iy)   {(ix) * WIDTH/4 + WIDTH/8, (iy) * HEIGHT/4 + HEIGHT/8}
 

Typedefs

typedef struct tagBITMAPINFOEX BITMAPINFOEX
 
typedef struct tagBITMAPINFOEXLPBITMAPINFOEX
 
typedef struct TEST_ENTRY TEST_ENTRY
 

Functions

static void DoTestEntry (const TEST_ENTRY *entry, HDC hDC, HBITMAP hbm)
 
 START_TEST (TextTransform)
 

Variables

static const RECT s_rc = {0, 0, WIDTH, HEIGHT}
 
static HBRUSH s_hWhiteBrush = NULL
 
static HPEN s_hRedPen = NULL
 
static const TEST_ENTRY s_entries []
 

Macro Definition Documentation

◆ BLACK

#define BLACK   RGB(0, 0, 0)

Definition at line 106 of file TextTransform.c.

◆ HEIGHT

#define HEIGHT   200

Definition at line 103 of file TextTransform.c.

◆ LFESCAPE1

#define LFESCAPE1   (-90 * 10)

Definition at line 110 of file TextTransform.c.

◆ LFHEIGHT

#define LFHEIGHT   -50

Definition at line 108 of file TextTransform.c.

◆ LFWIDTH1

#define LFWIDTH1   100

Definition at line 109 of file TextTransform.c.

◆ POS

#define POS (   ix,
  iy 
)    {(ix) * WIDTH/4 + WIDTH/8, (iy) * HEIGHT/4 + HEIGHT/8}

◆ WHITE

#define WHITE   RGB(255, 255, 255)

Definition at line 107 of file TextTransform.c.

◆ WIDTH

#define WIDTH   200

Definition at line 102 of file TextTransform.c.

◆ XCENTER

#define XCENTER   (WIDTH / 2)

Definition at line 104 of file TextTransform.c.

◆ YCENTER

#define YCENTER   (HEIGHT / 2)

Definition at line 105 of file TextTransform.c.

Typedef Documentation

◆ BITMAPINFOEX

◆ LPBITMAPINFOEX

◆ TEST_ENTRY

Function Documentation

◆ DoTestEntry()

static void DoTestEntry ( const TEST_ENTRY entry,
HDC  hDC,
HBITMAP  hbm 
)
static

Definition at line 304 of file TextTransform.c.

305{
306 HGDIOBJ hbmOld, hPenOld;
307 INT i, j;
308 BOOL ret;
309 static const WCHAR s_szBlackBoxes[] = L"gg";
310 LOGFONTA lf;
311 HFONT hFont;
312 HGDIOBJ hFontOld;
313
314 ZeroMemory(&lf, sizeof(lf));
315 lf.lfHeight = LFHEIGHT;
316 lf.lfWidth = entry->lfWidth;
317 lf.lfEscapement = entry->lfEscapement;
319 lstrcpyA(lf.lfFaceName, "Marlett");
321 ok(hFont != NULL, "hFont was NULL.\n");
322 hFontOld = SelectObject(hDC, hFont);
323
324 SetGraphicsMode(hDC, entry->GraphicsMode);
325
326 hbmOld = SelectObject(hDC, hbm);
327 {
329
331
332 hPenOld = SelectObject(hDC, s_hRedPen);
333 {
334 MoveToEx(hDC, XCENTER / 2, 0, NULL);
335 LineTo(hDC, XCENTER / 2, HEIGHT);
336
337 MoveToEx(hDC, XCENTER, 0, NULL);
339
340 MoveToEx(hDC, XCENTER * 3 / 2, 0, NULL);
341 LineTo(hDC, XCENTER * 3 / 2, HEIGHT);
342
343 MoveToEx(hDC, 0, YCENTER / 2, NULL);
344 LineTo(hDC, WIDTH, YCENTER / 2);
345
346 MoveToEx(hDC, 0, YCENTER, NULL);
348
349 MoveToEx(hDC, 0, YCENTER * 3 / 2, NULL);
350 LineTo(hDC, WIDTH, YCENTER * 3 / 2);
351 }
352 SelectObject(hDC, hPenOld);
353
354 ret = SetWorldTransform(hDC, &entry->xform);
355 ok(ret == entry->xform_ok, "Line %d: SetWorldTransform returned %d\n", entry->line, ret);
356
357 SetTextAlign(hDC, entry->TextAlign);
358
359 TextOutW(hDC, entry->ptRef.x, entry->ptRef.y, s_szBlackBoxes, lstrlenW(s_szBlackBoxes));
360
362
363#define POS(ix, iy) {(ix) * WIDTH/4 + WIDTH/8, (iy) * HEIGHT/4 + HEIGHT/8}
364
365 for (j = 0; j < 4; ++j)
366 {
367 for (i = 0; i < 4; ++i)
368 {
369 POINT pt = POS(i, j);
370 INT k = j * 4 + i + 1;
371 COLORREF rgb = GetPixel(hDC, pt.x, pt.y);
372 BOOL bFound = FALSE;
373 INT m;
374 for (m = 0; m < _countof(entry->aBlacks); ++m)
375 {
376 if (entry->aBlacks[m] == 0)
377 break;
378 if (entry->aBlacks[m] == k)
379 {
380 bFound = TRUE;
381 break;
382 }
383 }
384
385 if (bFound)
386 {
387 ok(rgb == RGB(0, 0, 0), "Line %d: It was not black (k: %d)\n", entry->line, k);
388 }
389 else
390 {
391 ok(rgb != RGB(0, 0, 0), "Line %d: It was black (k: %d)\n", entry->line, k);
392 }
393
394#ifdef DEBUGGING
395 {
396 WCHAR sz[8];
397 RECT rc;
398 COLORREF colorOld;
400 if (rgb == RGB(0, 0, 0))
401 {
402 if (!bFound)
403 printf("Line %d: k: %d\n", entry->line, k);
404 }
405 Ellipse(hDC, pt.x - 10, pt.y - 10, pt.x + 10, pt.y + 10);
406 SetRect(&rc, pt.x - 10, pt.y - 10, pt.x + 10, pt.y + 10);
407 StringCchPrintfW(sz, _countof(sz), L"%d", k);
408 colorOld = SetTextColor(hDC, RGB(255, 0, 0));
411 SetTextColor(hDC, colorOld);
412 SelectObject(hDC, hFontOld);
413 }
414#endif
415 }
416 }
417 }
418 SelectObject(hDC, hbmOld);
419
420#ifdef DEBUGGING
421 {
422 WCHAR szFileName[MAX_PATH];
423 StringCchPrintfW(szFileName, _countof(szFileName), L"Line%04u.bmp", entry->line);
424 SaveBitmapToFile(szFileName, hbm);
425 }
426#endif
427
428 SelectObject(hDC, hFontOld);
430}
static HDC hDC
Definition: 3dtext.c:33
static HBRUSH s_hWhiteBrush
static const RECT s_rc
#define WIDTH
#define YCENTER
#define XCENTER
#define LFHEIGHT
#define POS(ix, iy)
static HPEN s_hRedPen
#define HEIGHT
#define ok(value,...)
Definition: atltest.h:57
HFONT hFont
Definition: main.c:53
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
#define lstrlenW
Definition: compat.h:750
#define pt(x, y)
Definition: drawing.c:79
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
#define printf
Definition: freeldr.h:97
pKey DeleteObject()
const GLfloat * m
Definition: glext.h:10848
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
uint32_t entry
Definition: isohybrid.c:63
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
int k
Definition: mpi.c:3369
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define L(x)
Definition: ntvdm.h:50
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
LONG lfHeight
Definition: dimm.idl:42
LONG lfEscapement
Definition: dimm.idl:44
BYTE lfCharSet
Definition: dimm.idl:50
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
LONG lfWidth
Definition: dimm.idl:43
int32_t INT
Definition: typedefs.h:58
int ret
#define ZeroMemory
Definition: winbase.h:1712
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3521
DWORD COLORREF
Definition: windef.h:300
#define TA_NOUPDATECP
Definition: wingdi.h:935
HGDIOBJ WINAPI GetStockObject(_In_ int)
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1226
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:883
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define TA_LEFT
Definition: wingdi.h:932
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define MWT_IDENTITY
Definition: wingdi.h:944
#define TA_TOP
Definition: wingdi.h:930
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI ModifyWorldTransform(_In_ HDC, _In_opt_ const XFORM *, _In_ DWORD)
#define DT_CENTER
Definition: winuser.h:527
#define DT_SINGLELINE
Definition: winuser.h:540
#define DT_VCENTER
Definition: winuser.h:543
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( TextTransform  )

Definition at line 432 of file TextTransform.c.

433{
434 HDC hDC;
435 BITMAPINFO bmi;
436 LPVOID pvBits;
437 HBITMAP hbm;
438 UINT i;
439
441 s_hRedPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0));
442
444 ok(hDC != NULL, "hDC was NULL.\n");
445
447
448 ZeroMemory(&bmi, sizeof(bmi));
449 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
450 bmi.bmiHeader.biWidth = WIDTH;
452 bmi.bmiHeader.biPlanes = 1;
453 bmi.bmiHeader.biBitCount = 24;
454 hbm = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pvBits, NULL, 0);
455 ok(hbm != NULL, "hbm was NULL.\n");
456
457 for (i = 0; i < _countof(s_entries); ++i)
458 {
460 }
461
463
466
467 DeleteDC(hDC);
468}
static void DoTestEntry(const TEST_ENTRY *entry, HDC hDC, HBITMAP hbm)
static const TEST_ENTRY s_entries[]
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
USHORT biBitCount
Definition: precomp.h:46
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
#define WHITE_BRUSH
Definition: wingdi.h:902
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 116 of file TextTransform.c.

Referenced by START_TEST().

◆ s_hRedPen

HPEN s_hRedPen = NULL
static

Definition at line 114 of file TextTransform.c.

Referenced by DoTestEntry(), and START_TEST().

◆ s_hWhiteBrush

HBRUSH s_hWhiteBrush = NULL
static

Definition at line 113 of file TextTransform.c.

Referenced by DoTestEntry(), and START_TEST().

◆ s_rc

const RECT s_rc = {0, 0, WIDTH, HEIGHT}
static

Definition at line 112 of file TextTransform.c.

Referenced by DoTestEntry().