return str;
}
-static inline int get_stride(int width, int depth)
-{
- return ((depth * width + 31) >> 3) & ~3;
-}
-
static WINE_HIC* MSVIDEO_FirstHic /* = NULL */;
typedef struct _reg_driver reg_driver;
HIC hic,LPBITMAPINFOHEADER lpbiIn,LPBITMAPINFOHEADER lpbiOut,
INT depth,INT dx,INT dy)
{
- static const struct
- {
- int depth;
- int compression;
- }
- try_depths[] =
- {
- { 8, BI_RGB},
- {16, BI_RGB},
- {16, BI_BITFIELDS},
- {24, BI_RGB},
- {32, BI_RGB},
- };
+ HIC tmphic = hic;
- int screen_depth, i;
- BOOL found = FALSE;
- HIC tmphic;
- HDC hdc;
+ TRACE("(%p,%p,%p,%d,%d,%d)!\n",hic,lpbiIn,lpbiOut,depth,dx,dy);
- TRACE("(%p,%p,%p,%d,%d,%d)!\n", hic, lpbiIn, lpbiOut, depth, dx, dy);
-
- tmphic = hic ? hic : ICLocate(ICTYPE_VIDEO, 0, lpbiIn, NULL, ICMODE_DECOMPRESS);
- if (!tmphic) return tmphic;
-
- hdc = GetDC(0);
- screen_depth = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
- ReleaseDC(0, hdc);
-
- if (dx <= 0) dx = lpbiIn->biWidth;
- if (dy <= 0) dy = lpbiIn->biHeight;
- if (!depth) depth = screen_depth;
+ if (!tmphic) {
+ tmphic=ICLocate(ICTYPE_VIDEO,0,lpbiIn,NULL,ICMODE_DECOMPRESS);
+ if (!tmphic)
+ return tmphic;
+ }
+ if ((dy == lpbiIn->biHeight) && (dx == lpbiIn->biWidth))
+ dy = dx = 0; /* no resize needed */
/* Can we decompress it ? */
- if (ICDecompressQuery(tmphic, lpbiIn, NULL) != ICERR_OK)
+ if (ICDecompressQuery(tmphic,lpbiIn,NULL) != 0)
goto errout; /* no, sorry */
ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)lpbiIn, (DWORD_PTR)lpbiOut);
- lpbiOut->biSize = sizeof(BITMAPINFOHEADER);
- lpbiOut->biWidth = dx;
- lpbiOut->biHeight = dy;
- lpbiOut->biPlanes = 1;
-
- for (i = 0; i < sizeof(try_depths) / sizeof(try_depths[0]); i++)
- {
- if (!found && try_depths[i].depth != depth)
- continue;
-
- found = TRUE;
- lpbiOut->biBitCount = try_depths[i].depth;
- lpbiOut->biCompression = try_depths[i].compression;
- lpbiOut->biSizeImage = dx * get_stride(dy, lpbiOut->biBitCount);
-
- if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
- {
- if (try_depths[i].depth == 8)
- ICDecompressGetPalette(tmphic, lpbiIn, lpbiOut);
- goto success;
- }
- }
-
- if (!found)
- {
- lpbiOut->biBitCount = depth;
- lpbiOut->biCompression = BI_RGB;
- lpbiOut->biSizeImage = dx * get_stride(dy, lpbiOut->biBitCount);
- if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
- goto success;
-
- lpbiOut->biBitCount = screen_depth;
- lpbiOut->biCompression = BI_RGB;
- lpbiOut->biSizeImage = dx * get_stride(dy, lpbiOut->biBitCount);
- if (ICDecompressQuery(tmphic, lpbiIn, lpbiOut) == ICERR_OK)
- goto success;
- }
-
- if (ICSendMessage(tmphic, ICM_DECOMPRESS_GET_FORMAT, (DWORD_PTR)lpbiIn, (DWORD_PTR)lpbiOut))
- goto errout;
-
- if (lpbiOut->biCompression != 0) {
+ if (lpbiOut->biCompression != 0) {
FIXME("Ooch, how come decompressor outputs compressed data (%d)??\n",
lpbiOut->biCompression);
}
lpbiOut->biSize);
lpbiOut->biSize = sizeof(*lpbiOut);
}
+ if (!depth) {
+ HDC hdc;
+
+ hdc = GetDC(0);
+ depth = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
+ ReleaseDC(0,hdc);
+ if (depth==15) depth = 16;
+ if (depth<8) depth = 8;
+ }
+ if (lpbiIn->biBitCount == 8)
+ depth = 8;
-success:
TRACE("=> %p\n", tmphic);
return tmphic;
-
errout:
if (hic!=tmphic)
ICClose(tmphic);