winhttp: Verify SSL policy of chains whose errors were ignored.
[wine/multimedia.git] / dlls / windowscodecs / main.c
blobff543d5000f68fbf22851c4ddead1fca14155f96
1 /*
2 * Copyright 2009 Vincent Povirk for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "objbase.h"
27 #include "wincodec.h"
29 #include "wincodecs_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
35 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
38 switch (fdwReason)
40 case DLL_PROCESS_ATTACH:
41 DisableThreadLibraryCalls(hinstDLL);
42 break;
43 case DLL_PROCESS_DETACH:
44 break;
47 return TRUE;
50 HRESULT copy_pixels(UINT bpp, const BYTE *srcbuffer,
51 UINT srcwidth, UINT srcheight, INT srcstride,
52 const WICRect *rc, UINT dststride, UINT dstbuffersize, BYTE *dstbuffer)
54 UINT bytesperrow;
55 UINT row_offset; /* number of bits into the source rows where the data starts */
57 if (rc->X < 0 || rc->Y < 0 || rc->X+rc->Width > srcwidth || rc->Y+rc->Height > srcheight)
58 return E_INVALIDARG;
60 bytesperrow = ((bpp * rc->Width)+7)/8;
62 if (dststride < bytesperrow)
63 return E_INVALIDARG;
65 if ((dststride * rc->Height) > dstbuffersize)
66 return E_INVALIDARG;
68 row_offset = rc->X * bpp;
70 if (row_offset % 8 == 0)
72 /* everything lines up on a byte boundary */
73 UINT row;
74 const BYTE *src;
75 BYTE *dst;
77 src = srcbuffer + (row_offset / 8) + srcstride * rc->Y;
78 dst = dstbuffer;
79 for (row=0; row < rc->Height; row++)
81 memcpy(dst, src, bytesperrow);
82 src += srcstride;
83 dst += dststride;
85 return S_OK;
87 else
89 /* we have to do a weird bitwise copy. eww. */
90 FIXME("cannot reliably copy bitmap data if bpp < 8\n");
91 return E_FAIL;