ReactOS  0.4.14-dev-358-gbef841c
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 SaveBitmapToFile(f, h)
 
#define WIDTH   400
 
#define HEIGHT   400
 
#define XCENTER   (WIDTH / 2)
 
#define YCENTER   (HEIGHT / 2)
 
#define BLACK   RGB(0, 0, 0)
 
#define WHITE   RGB(255, 255, 255)
 
#define LFHEIGHT   -100
 
#define POS(ix, iy)   {XCENTER + (ix) * WIDTH/8, YCENTER + (iy) * HEIGHT/8}
 
#define NO_TRANS_1   3, {POS(1, 1), POS(-1, 1), POS(-1, -1)}, 1, {POS(1, -1)}
 
#define NO_TRANS_2   3, {POS(1, -1), POS(-1, 1), POS(-1, -1)}, 1, {POS(1, 1)}
 

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 []
 
static const INT s_entry_count = (INT)(sizeof(s_entries) / sizeof(s_entries[0]))
 

Macro Definition Documentation

◆ BLACK

#define BLACK   RGB(0, 0, 0)

Definition at line 108 of file TextTransform.c.

◆ HEIGHT

#define HEIGHT   400

Definition at line 105 of file TextTransform.c.

◆ LFHEIGHT

#define LFHEIGHT   -100

Definition at line 110 of file TextTransform.c.

◆ NO_TRANS_1

#define NO_TRANS_1   3, {POS(1, 1), POS(-1, 1), POS(-1, -1)}, 1, {POS(1, -1)}

Definition at line 118 of file TextTransform.c.

◆ NO_TRANS_2

#define NO_TRANS_2   3, {POS(1, -1), POS(-1, 1), POS(-1, -1)}, 1, {POS(1, 1)}

Definition at line 121 of file TextTransform.c.

◆ POS

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

Definition at line 116 of file TextTransform.c.

◆ SaveBitmapToFile

#define SaveBitmapToFile (   f,
  h 
)

Definition at line 17 of file TextTransform.c.

◆ WHITE

#define WHITE   RGB(255, 255, 255)

Definition at line 109 of file TextTransform.c.

◆ WIDTH

#define WIDTH   400

Definition at line 104 of file TextTransform.c.

◆ XCENTER

#define XCENTER   (WIDTH / 2)

Definition at line 106 of file TextTransform.c.

◆ YCENTER

#define YCENTER   (HEIGHT / 2)

Definition at line 107 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 262 of file TextTransform.c.

263 {
264  HGDIOBJ hbmOld, hPenOld;
265  INT i;
266  COLORREF rgb;
267  BOOL ret;
268  static const WCHAR s_chBlackBox = L'g';
269 
270  SetGraphicsMode(hDC, entry->GraphicsMode);
271 
272  hbmOld = SelectObject(hDC, hbm);
273  {
275 
277 
278  hPenOld = SelectObject(hDC, s_hRedPen);
279  {
280  MoveToEx(hDC, XCENTER / 2, 0, NULL);
281  LineTo(hDC, XCENTER / 2, HEIGHT);
282 
283  MoveToEx(hDC, XCENTER, 0, NULL);
285 
286  MoveToEx(hDC, XCENTER * 3 / 2, 0, NULL);
287  LineTo(hDC, XCENTER * 3 / 2, HEIGHT);
288 
289  MoveToEx(hDC, 0, YCENTER / 2, NULL);
290  LineTo(hDC, WIDTH, YCENTER / 2);
291 
292  MoveToEx(hDC, 0, YCENTER, NULL);
293  LineTo(hDC, WIDTH, YCENTER);
294 
295  MoveToEx(hDC, 0, YCENTER * 3 / 2, NULL);
296  LineTo(hDC, WIDTH, YCENTER * 3 / 2);
297  }
298  SelectObject(hDC, hPenOld);
299 
300  ret = SetWorldTransform(hDC, &entry->xform);
301  ok(ret == entry->xform_ok, "Line %d: SetWorldTransform returned %d\n", entry->line, ret);
302 
303  SetTextAlign(hDC, entry->TextAlign);
304 
305  TextOutW(hDC, entry->ptRef.x, entry->ptRef.y, &s_chBlackBox, 1);
306 
308 
309  for (i = 0; i < entry->cWhitePoints; ++i)
310  {
311  rgb = GetPixel(hDC, entry->WhitePoints[i].x, entry->WhitePoints[i].y);
312  ok(rgb == WHITE, "Line %d: %d: (%ld, %ld) is not white\n", entry->line, i,
313  entry->WhitePoints[i].x, entry->WhitePoints[i].y);
314  }
315 
316  for (i = 0; i < entry->cBlackPoints; ++i)
317  {
318  rgb = GetPixel(hDC, entry->BlackPoints[i].x, entry->BlackPoints[i].y);
319  ok(rgb == BLACK, "Line %d: %d: (%ld, %ld) is not black\n", entry->line, i,
320  entry->BlackPoints[i].x, entry->BlackPoints[i].y);
321  }
322  }
323  SelectObject(hDC, hbmOld);
324 
325  SaveBitmapToFile(entry->filename, hbm);
326 }
static HPEN s_hRedPen
#define SaveBitmapToFile(f, h)
Definition: TextTransform.c:17
#define HEIGHT
#define YCENTER
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
static HBRUSH s_hWhiteBrush
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:853
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
int32_t INT
Definition: typedefs.h:56
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
static const RECT s_rc
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define XCENTER
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define BLACK
DWORD COLORREF
Definition: windef.h:285
BOOL WINAPI ModifyWorldTransform(_In_ HDC, _In_opt_ const XFORM *, _In_ DWORD)
int ret
#define WHITE
static const WCHAR L[]
Definition: oid.c:1250
uint32_t entry
Definition: isohybrid.c:63
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
#define WIDTH
static HDC hDC
Definition: 3dtext.c:33
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3520
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define ok(value,...)
Definition: atltest.h:57
#define MWT_IDENTITY
Definition: wingdi.h:943
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( TextTransform  )

Definition at line 328 of file TextTransform.c.

329 {
330  HDC hDC;
331  BITMAPINFO bmi;
332  LPVOID pvBits;
333  HBITMAP hbm;
334  LOGFONTA lf;
335  HFONT hFont;
336  HGDIOBJ hFontOld;
337  INT i;
338 
340  s_hRedPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
341 
343  ok(hDC != NULL, "hDC was NULL.\n");
344 
347 
348  ZeroMemory(&bmi, sizeof(bmi));
349  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
350  bmi.bmiHeader.biWidth = WIDTH;
351  bmi.bmiHeader.biHeight = HEIGHT;
352  bmi.bmiHeader.biPlanes = 1;
353  bmi.bmiHeader.biBitCount = 24;
354  hbm = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pvBits, NULL, 0);
355  ok(hbm != NULL, "hbm was NULL.\n");
356 
357  ZeroMemory(&lf, sizeof(lf));
358  lf.lfHeight = LFHEIGHT;
360  lstrcpyA(lf.lfFaceName, "Marlett");
361  hFont = CreateFontIndirectA(&lf);
362  ok(hFont != NULL, "hFont was NULL.\n");
363 
364  hFontOld = SelectObject(hDC, hFont);
365  for (i = 0; i < s_entry_count; ++i)
366  {
368  }
369  SelectObject(hDC, hFontOld);
370 
372  DeleteObject(hbm);
373 
376 
377  DeleteDC(hDC);
378 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
static HPEN s_hRedPen
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
static void DoTestEntry(const TEST_ENTRY *entry, HDC hDC, HBITMAP hbm)
static const TEST_ENTRY s_entries[]
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static HDC
Definition: imagelist.c:92
#define HEIGHT
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1642
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define WHITE_BRUSH
Definition: wingdi.h:901
BYTE lfCharSet
Definition: dimm.idl:50
static HBRUSH s_hWhiteBrush
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define LFHEIGHT
#define DEFAULT_CHARSET
Definition: wingdi.h:383
int32_t INT
Definition: typedefs.h:56
HFONT hFont
Definition: main.c:53
#define PS_SOLID
Definition: wingdi.h:585
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
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
int WINAPI SetMapMode(_In_ HDC, _In_ int)
LONG lfHeight
Definition: dimm.idl:42
#define TRANSPARENT
Definition: wingdi.h:949
smooth NULL
Definition: ftsmooth.c:416
#define RGB(r, g, b)
Definition: wingdi.h:2935
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define MM_ANISOTROPIC
Definition: wingdi.h:866
#define WIDTH
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define ok(value,...)
Definition: atltest.h:57
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const INT s_entry_count
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:366

Variable Documentation

◆ s_entries

const TEST_ENTRY s_entries[]
static

Definition at line 124 of file TextTransform.c.

Referenced by START_TEST().

◆ s_entry_count

const INT s_entry_count = (INT)(sizeof(s_entries) / sizeof(s_entries[0]))
static

Definition at line 260 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().