From e20413bf6b872a8c23f1704a89295c5897347c9d Mon Sep 17 00:00:00 2001 From: pierrejoye Date: Wed, 3 Apr 2013 14:23:11 +0200 Subject: - apply same CS everywhere --- examples/arc.c | 2 +- examples/copyrotated.c | 10 +-- examples/crop.c | 2 +- examples/flip.c | 4 +- examples/gif.c | 2 +- examples/nnquant.c | 2 +- examples/tgaread.c | 4 +- examples/tiffread.c | 4 +- examples/windows.c | 223 ++++++++++++++++++++++++------------------------- 9 files changed, 124 insertions(+), 129 deletions(-) (limited to 'examples') diff --git a/examples/arc.c b/examples/arc.c index b9d504b..ae3fcfd 100644 --- a/examples/arc.c +++ b/examples/arc.c @@ -5,7 +5,7 @@ int main() { - gdImagePtr im; + gdImagePtr im; FILE *fp; int cor_rad = 60; im = gdImageCreateTrueColor(400, 400); diff --git a/examples/copyrotated.c b/examples/copyrotated.c index 8bfdac2..03e493d 100644 --- a/examples/copyrotated.c +++ b/examples/copyrotated.c @@ -35,9 +35,9 @@ int savePngImage(gdImagePtr im, const char *name) int main(int argc, char **arg) { - gdImagePtr im, im2; - int new_width, new_height; - double angle, a2; + gdImagePtr im, im2; + int new_width, new_height; + double angle, a2; if (argc < 3) { fprintf(stderr, "Usage: copyrotated [angle in degree] [filename.png]\n"); @@ -61,9 +61,9 @@ int main(int argc, char **arg) a2 = angle * .0174532925; new_width = ceil(cos(a2) * gdImageSX(im)) + - fabs(sin(a2) * gdImageSY(im)); + fabs(sin(a2) * gdImageSY(im)); new_height = ceil(cos(a2) * gdImageSY(im)) + - fabs(sin(a2) * gdImageSX(im)); + fabs(sin(a2) * gdImageSX(im)); im2 = gdImageCreateTrueColor(new_width, new_height); diff --git a/examples/crop.c b/examples/crop.c index c72c641..e12ea1f 100644 --- a/examples/crop.c +++ b/examples/crop.c @@ -33,7 +33,7 @@ gdImagePtr read_png(const char *filename) int main() { - gdImagePtr im, im2; + gdImagePtr im, im2; im = gdImageCreateTrueColor(400, 400); diff --git a/examples/flip.c b/examples/flip.c index 54a4572..2399457 100644 --- a/examples/flip.c +++ b/examples/flip.c @@ -33,8 +33,8 @@ int savePngImage(gdImagePtr im, const char *name) int main(int argc, char **arg) { - gdImagePtr im; - int returncode = 0; + gdImagePtr im; + int returncode = 0; if (argc < 2) { fprintf(stderr, "Usage: flip [filename.png]\n"); diff --git a/examples/gif.c b/examples/gif.c index 3e9d1bd..d5103f0 100644 --- a/examples/gif.c +++ b/examples/gif.c @@ -24,7 +24,7 @@ int main(void) } gdImageColorAllocate(im, 255, 255, 255); /* allocate white as side effect */ - gdImageGifAnimBegin(im, out, 1, -1); + gdImageGifAnimBegin(im, out, 1, -1); for(i = 0; i < 20; i++) { int r,g,b; diff --git a/examples/nnquant.c b/examples/nnquant.c index ebe7c70..c5f452d 100644 --- a/examples/nnquant.c +++ b/examples/nnquant.c @@ -19,7 +19,7 @@ void save_png(gdImagePtr im, const char *filename) int main() { #ifdef HAVE_JPEG - gdImagePtr im, im2; + gdImagePtr im, im2; FILE *fp; char path[2048]; diff --git a/examples/tgaread.c b/examples/tgaread.c index 1f7878d..018a3d4 100644 --- a/examples/tgaread.c +++ b/examples/tgaread.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * You can fetch a set of samples TIFF images here: - * ftp://ftp.remotesensing.org/pub/libtiff/ + * ftp://ftp.remotesensing.org/pub/libtiff/ * (pics-x.y.z.tar.gz) */ @@ -11,7 +11,7 @@ int main() { - gdImagePtr im; + gdImagePtr im; FILE *fp; char path[4][2048]; int i; diff --git a/examples/tiffread.c b/examples/tiffread.c index aaeded6..fe63ce0 100644 --- a/examples/tiffread.c +++ b/examples/tiffread.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * You can fetch a set of samples TIFF images here: - * ftp://ftp.remotesensing.org/pub/libtiff/ + * ftp://ftp.remotesensing.org/pub/libtiff/ * (pics-x.y.z.tar.gz) */ @@ -10,7 +10,7 @@ #include int main() { - gdImagePtr im; + gdImagePtr im; FILE *fp; char path[9][2048]; int i; diff --git a/examples/windows.c b/examples/windows.c index 05bf4c5..5597638 100644 --- a/examples/windows.c +++ b/examples/windows.c @@ -44,15 +44,15 @@ gdImagePtr gdImageTrueColorAttachBuffer(int* buffer, int sx, int sy, int stride) height = sy; rowptr = buffer; if (stride < 0) { - int startoff = (height - 1) * stride; - rowptr = buffer - startoff; + int startoff = (height - 1) * stride; + rowptr = buffer - startoff; } i = 0; while (height--) { - im->tpixels[i] = rowptr; - rowptr += stride; - i++; + im->tpixels[i] = rowptr; + rowptr += stride; + i++; } im->sx = sx; @@ -104,61 +104,60 @@ LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { - static TCHAR szAppName[] = TEXT ("Bezier") ; - HWND hwnd ; - MSG msg ; - WNDCLASS wndclass ; - - wndclass.style = CS_HREDRAW | CS_VREDRAW ; - wndclass.lpfnWndProc = WndProc ; - wndclass.cbClsExtra = 0 ; - wndclass.cbWndExtra = 0 ; - wndclass.hInstance = hInstance ; - wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; - wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; - wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; - wndclass.lpszMenuName = NULL ; - wndclass.lpszClassName = szAppName ; - - if (!RegisterClass (&wndclass)) - { // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit - MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode und setzt Windows NT voraus!"), - szAppName, MB_ICONERROR) ; - return 0 ; - } - - hwnd = CreateWindow (szAppName, TEXT ("Bezierkurven"), - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, hInstance, NULL) ; - - ShowWindow (hwnd, iCmdShow) ; - UpdateWindow (hwnd) ; - - while (GetMessage (&msg, NULL, 0, 0)) - { - TranslateMessage (&msg) ; - DispatchMessage (&msg) ; - } - return msg.wParam ; + static TCHAR szAppName[] = TEXT ("Bezier") ; + HWND hwnd ; + MSG msg ; + WNDCLASS wndclass ; + + wndclass.style = CS_HREDRAW | CS_VREDRAW ; + wndclass.lpfnWndProc = WndProc ; + wndclass.cbClsExtra = 0 ; + wndclass.cbWndExtra = 0 ; + wndclass.hInstance = hInstance ; + wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; + wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; + wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; + wndclass.lpszMenuName = NULL ; + wndclass.lpszClassName = szAppName ; + + if (!RegisterClass (&wndclass)) { + // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit + MessageBox (NULL, TEXT ("Programm arbeitet mit Unicode und setzt Windows NT voraus!"), + szAppName, MB_ICONERROR) ; + return 0 ; + } + + hwnd = CreateWindow (szAppName, TEXT ("Bezierkurven"), + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + NULL, NULL, hInstance, NULL) ; + + ShowWindow (hwnd, iCmdShow) ; + UpdateWindow (hwnd) ; + + while (GetMessage (&msg, NULL, 0, 0)) { + TranslateMessage (&msg) ; + DispatchMessage (&msg) ; + } + return msg.wParam ; } void DrawBezier (HDC hdc, POINT apt[]) { - PolyBezier (hdc, apt, 4) ; + PolyBezier (hdc, apt, 4) ; - MoveToEx (hdc, apt[0].x, apt[0].y, NULL) ; - LineTo (hdc, apt[1].x, apt[1].y) ; + MoveToEx (hdc, apt[0].x, apt[0].y, NULL) ; + LineTo (hdc, apt[1].x, apt[1].y) ; - MoveToEx (hdc, apt[2].x, apt[2].y, NULL) ; - LineTo (hdc, apt[3].x, apt[3].y) ; + MoveToEx (hdc, apt[2].x, apt[2].y, NULL) ; + LineTo (hdc, apt[3].x, apt[3].y) ; } void gdDrawImage(HDC hdc, RECT *rc) { - HDC mem_dc; + HDC mem_dc; BITMAPINFO bmp_info; void* bits; HBITMAP bmp, temp; @@ -223,9 +222,9 @@ void gdDrawImage(HDC hdc, RECT *rc) gdImageLine(im, 0, 0, 150, 150, black); gdImageString(im, gdFontGetLarge(), - im->sx / 2 - (strlen(s) * lfont->w / 2), - im->sy / 2 - lfont->h / 2, - (unsigned char*)s, black); + im->sx / 2 - (strlen(s) * lfont->w / 2), + im->sy / 2 - lfont->h / 2, + (unsigned char*)s, black); // Copy drawing from memory context (shared bitmap buffer) to screen DC. BitBlt(hdc, rc->left, rc->top, width, height, mem_dc, 0, 0, SRCCOPY); @@ -239,66 +238,62 @@ void gdDrawImage(HDC hdc, RECT *rc) LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - static POINT apt[4] ; - HDC hdc ; - int cxClient, cyClient ; - PAINTSTRUCT ps ; - RECT rc; + static POINT apt[4] ; + HDC hdc ; + int cxClient, cyClient ; + PAINTSTRUCT ps ; + RECT rc; GetClientRect(hwnd, &rc); - switch (message) - { - case WM_SIZE: - cxClient = LOWORD (lParam) ; - cyClient = HIWORD (lParam) ; - - apt[0].x = cxClient / 4 ; - apt[0].y = cyClient / 2 ; - - apt[1].x = cxClient / 2 ; - apt[1].y = cyClient / 4 ; - - apt[2].x = cxClient / 2 ; - apt[2].y = 3 * cyClient / 4 ; - - apt[3].x = 3 * cxClient / 4 ; - apt[3].y = cyClient / 2 ; - return 0 ; - - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MOUSEMOVE: - if (wParam & MK_LBUTTON || wParam & MK_RBUTTON) - { - hdc = GetDC (hwnd) ; - - // alte Kurve löschen (mit Weiß übermalen) - SelectObject (hdc, GetStockObject (WHITE_PEN)) ; - DrawBezier (hdc, apt) ; - - if (wParam & MK_LBUTTON) - { - apt[1].x = LOWORD (lParam) ; - apt[1].y = HIWORD (lParam) ; - } - - if (wParam & MK_RBUTTON) - { - apt[2].x = LOWORD (lParam) ; - apt[2].y = HIWORD (lParam) ; - } - - // neue Kurve (mit Schwarz) zeichnen - SelectObject (hdc, GetStockObject (BLACK_PEN)) ; - gdDrawImage(hdc, &rc); - DrawBezier (hdc, apt) ; - ReleaseDC (hwnd, hdc) ; - } - return 0 ; - - - case WM_PAINT: + switch (message) { + case WM_SIZE: + cxClient = LOWORD (lParam) ; + cyClient = HIWORD (lParam) ; + + apt[0].x = cxClient / 4 ; + apt[0].y = cyClient / 2 ; + + apt[1].x = cxClient / 2 ; + apt[1].y = cyClient / 4 ; + + apt[2].x = cxClient / 2 ; + apt[2].y = 3 * cyClient / 4 ; + + apt[3].x = 3 * cxClient / 4 ; + apt[3].y = cyClient / 2 ; + return 0 ; + + case WM_LBUTTONDOWN: + case WM_RBUTTONDOWN: + case WM_MOUSEMOVE: + if (wParam & MK_LBUTTON || wParam & MK_RBUTTON) { + hdc = GetDC (hwnd) ; + + // alte Kurve löschen (mit Weiß übermalen) + SelectObject (hdc, GetStockObject (WHITE_PEN)) ; + DrawBezier (hdc, apt) ; + + if (wParam & MK_LBUTTON) { + apt[1].x = LOWORD (lParam) ; + apt[1].y = HIWORD (lParam) ; + } + + if (wParam & MK_RBUTTON) { + apt[2].x = LOWORD (lParam) ; + apt[2].y = HIWORD (lParam) ; + } + + // neue Kurve (mit Schwarz) zeichnen + SelectObject (hdc, GetStockObject (BLACK_PEN)) ; + gdDrawImage(hdc, &rc); + DrawBezier (hdc, apt) ; + ReleaseDC (hwnd, hdc) ; + } + return 0 ; + + + case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; GetClientRect(hwnd, &rc); @@ -308,9 +303,9 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) EndPaint (hwnd, &ps) ; return 0 ; - case WM_DESTROY: - PostQuitMessage (0) ; - return 0 ; - } - return DefWindowProc (hwnd, message, wParam, lParam) ; + case WM_DESTROY: + PostQuitMessage (0) ; + return 0 ; + } + return DefWindowProc (hwnd, message, wParam, lParam) ; } -- cgit v1.2.1