Changeset 2635 for trunk/src/comctl32/imagelist.c
- Timestamp:
- Feb 4, 2000, 6:02:09 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/imagelist.c
r2126 r2635 1 /* $Id: imagelist.c,v 1.1 0 1999-12-18 20:56:58 achimhaExp $ */1 /* $Id: imagelist.c,v 1.11 2000-02-04 17:02:07 cbratschi Exp $ */ 2 2 /* 3 3 * ImageList implementation 4 4 * 5 5 * Copyright 1998 Eric Kohl 6 * Copyright 1999 Achim Hasenmueller 6 * Copyright 1999 Achim Hasenmueller 7 * Copyright 2000 Christoph Bratschi 7 8 * 8 9 * TODO: … … 10 11 * - Fix ImageList_GetIcon. 11 12 * - Fix drag functions. 12 * - Fix ImageList_ Read and ImageList_Write.13 * - Fix ImageList_Write. 13 14 * - Fix ImageList_SetFilter (undocumented). 14 15 * BTW does anybody know anything about this function??? … … 26 27 27 28 /* CB: todo 28 - ImageList_Read29 29 - ImageList_Write 30 30 */ 31 31 32 /* WINE 991212level */32 /* WINE 20000130 level */ 33 33 34 34 /* This must be defined because the HIMAGELIST type is just a pointer … … 38 38 */ 39 39 #define __WINE_IMAGELIST_C 40 41 #include "wine/obj_base.h" 42 #include "wine/obj_storage.h" 40 43 41 44 #include "imagelist.h" … … 169 172 HDC hImageDC; 170 173 HBITMAP hOldBitmap; 174 171 175 hImageDC = CreateCompatibleDC(0); 172 176 hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage); … … 223 227 */ 224 228 if( bUseCustomBackground && (pimldp->fStyle == ILD_NORMAL 225 || pimldp->fStyle & ILD_IMAGE229 || (pimldp->fStyle & ILD_IMAGE) 226 230 || bBlendFlag)) 227 231 { … … 238 242 */ 239 243 if(pimldp->fStyle == ILD_NORMAL 240 || pimldp->fStyle & ILD_TRANSPARENT244 || (pimldp->fStyle & ILD_TRANSPARENT) 241 245 || ((pimldp->fStyle & ILD_IMAGE) && bUseCustomBackground) 242 246 || bBlendFlag) … … 265 269 /* Draw the image when no Background is specified 266 270 */ 267 else if( pimldp->fStyle & ILD_IMAGE&& !bUseCustomBackground)271 else if((pimldp->fStyle & ILD_IMAGE) && !bUseCustomBackground) 268 272 { 269 273 BitBlt(pimldp->hdcDst, … … 1339 1343 DeleteDC (hdcDst); 1340 1344 DeleteDC (hdcSrc); 1345 1346 himlDst->cCurImage = himlSrc->cCurImage; 1347 himlDst->cMaxImage = himlSrc->cMaxImage; 1341 1348 } 1342 1349 … … 1888 1895 1889 1896 1897 /* helper for _read_bitmap currently unused */ 1898 static int may_use_dibsection(HDC hdc) { 1899 int bitspixel = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES); 1900 if (bitspixel>8) 1901 return TRUE; 1902 if (bitspixel<=4) 1903 return FALSE; 1904 return GetDeviceCaps(hdc,94) & 0x10; 1905 } 1906 1907 /* helper for ImageList_Read, see comments below */ 1908 static HBITMAP _read_bitmap(LPSTREAM pstm,int ilcFlag,int cx,int cy) { 1909 HDC xdc = 0; 1910 BITMAPFILEHEADER bmfh; 1911 BITMAPINFOHEADER bmih; 1912 int bitsperpixel,palspace,longsperline,width,height; 1913 LPBITMAPINFOHEADER bmihc = NULL; 1914 int result = 0; 1915 HBITMAP hbitmap = 0; 1916 LPBYTE bits = NULL,nbits = NULL; 1917 int nbytesperline,bytesperline; 1918 1919 if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL)) || 1920 (bmfh.bfType != (('M'<<8)|'B')) || 1921 !SUCCEEDED(IStream_Read ( pstm, &bmih, sizeof(bmih), NULL)) || 1922 (bmih.biSize != sizeof(bmih)) 1923 ) 1924 return 0; 1925 1926 bitsperpixel = bmih.biPlanes * bmih.biBitCount; 1927 if (bitsperpixel<=8) 1928 palspace = (1<<bitsperpixel)*sizeof(RGBQUAD); 1929 else 1930 palspace = 0; 1931 width = bmih.biWidth; 1932 height = bmih.biHeight; 1933 bmihc = (LPBITMAPINFOHEADER)LocalAlloc(LMEM_ZEROINIT,sizeof(bmih)+palspace); 1934 memcpy(bmihc,&bmih,sizeof(bmih)); 1935 longsperline = ((width*bitsperpixel+31)&~0x1f)>>5; 1936 bmihc->biSizeImage = (longsperline*height)<<2; 1937 1938 /* read the palette right after the end of the bitmapinfoheader */ 1939 if (palspace) 1940 if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL))) 1941 goto ret1; 1942 1943 xdc = GetDC(0); 1944 #if 0 /* Magic for NxM -> 1x(N*M) not implemented for DIB Sections */ 1945 if ((bitsperpixel>1) && 1946 ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc))) 1947 ) { 1948 hbitmap = CreateDIBSection(xdc,(BITMAPINFO*)bmihc,0,(LPVOID*)&bits,0,0); 1949 if (!hbitmap) 1950 goto ret1; 1951 if (!SUCCEEDED(IStream_Read( pstm, bits, bmihc->biSizeImage, NULL))) 1952 goto ret1; 1953 result = 1; 1954 } else 1955 #endif 1956 { 1957 int i,nwidth,nheight; 1958 1959 nwidth = width*(height/cy); 1960 nheight = cy; 1961 1962 if (bitsperpixel==1) 1963 hbitmap = CreateBitmap(nwidth,nheight,1,1,NULL); 1964 else 1965 hbitmap = CreateCompatibleBitmap(xdc,nwidth,nheight); 1966 1967 /* Might be a bit excessive memory use here */ 1968 bits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); 1969 nbits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); 1970 if (!SUCCEEDED(IStream_Read ( pstm, bits, bmihc->biSizeImage, NULL))) 1971 goto ret1; 1972 1973 /* Copy the NxM bitmap into a 1x(N*M) bitmap we need, linewise */ 1974 /* Do not forget that windows bitmaps are bottom->top */ 1975 bytesperline = longsperline*4; 1976 nbytesperline = (height/cy)*bytesperline; 1977 for (i=0;i<height;i++) { 1978 memcpy( 1979 nbits+((height-i)%cy)*nbytesperline+(i/cy)*bytesperline, 1980 bits+bytesperline*(height-i), 1981 bytesperline 1982 ); 1983 } 1984 bmihc->biWidth = nwidth; 1985 bmihc->biHeight = nheight; 1986 if (!SetDIBits(xdc,hbitmap,0,nheight,nbits,(BITMAPINFO*)bmihc,0)) 1987 goto ret1; 1988 LocalFree((HLOCAL)nbits); 1989 LocalFree((HLOCAL)bits); 1990 result = 1; 1991 } 1992 ret1: 1993 if (xdc) ReleaseDC(0,xdc); 1994 if (bmihc) LocalFree((HLOCAL)bmihc); 1995 if (!result) { 1996 if (hbitmap) { 1997 DeleteObject(hbitmap); 1998 hbitmap = 0; 1999 } 2000 } 2001 return hbitmap; 2002 } 2003 1890 2004 /************************************************************************* 1891 2005 * ImageList_Read [COMCTL32.66] … … 1900 2014 * Failure: NULL 1901 2015 * 1902 * NOTES 1903 * This function can not be implemented yet, because 1904 * IStream32::Read is not implemented yet. 1905 * 1906 * BUGS 1907 * empty stub. 1908 */ 1909 1910 //HIMAGELIST WINAPI ImageList_Read (LPSTREAM pstm) 1911 HIMAGELIST WINAPI ImageList_Read (PVOID pstm) 1912 { 1913 // HRESULT errCode; 1914 // ULONG ulRead; 1915 // ILHEAD ilHead; 1916 // HIMAGELIST himl; 1917 1918 1919 dprintf(("ImageList_Read empty stub!\n")); 1920 1921 // errCode = IStream_Read (pstm, &ilHead, sizeof(ILHEAD), &ulRead); 1922 // if (errCode != S_OK) 1923 // return NULL; 1924 1925 FIXME("Magic: 0x%x\n", ilHead.usMagic); 1926 1927 // himl = ImageList_Create (32, 32, ILD_NORMAL, 2, 2); 1928 1929 // return himl; 1930 return 0; 2016 * The format is like this: 2017 * ILHEAD ilheadstruct; 2018 * 2019 * for the color image part: 2020 * BITMAPFILEHEADER bmfh; 2021 * BITMAPINFOHEADER bmih; 2022 * only if it has a palette: 2023 * RGBQUAD rgbs[nr_of_paletted_colors]; 2024 * 2025 * BYTE colorbits[imagesize]; 2026 * 2027 * the following only if the ILC_MASK bit is set in ILHEAD.ilFlags: 2028 * BITMAPFILEHEADER bmfh_mask; 2029 * BITMAPINFOHEADER bmih_mask; 2030 * only if it has a palette (it usually does not): 2031 * RGBQUAD rgbs[nr_of_paletted_colors]; 2032 * 2033 * BYTE maskbits[imagesize]; 2034 * 2035 * CAVEAT: Those images are within a NxM bitmap, not the 1xN we expect. 2036 * _read_bitmap needs to convert them. 2037 */ 2038 HIMAGELIST WINAPI ImageList_Read (LPSTREAM pstm) 2039 { 2040 ILHEAD ilHead; 2041 HIMAGELIST himl; 2042 HBITMAP hbmColor=0,hbmMask=0; 2043 int i; 2044 2045 if (!SUCCEEDED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL))) 2046 return NULL; 2047 if (ilHead.usMagic != (('L' << 8) | 'I')) 2048 return NULL; 2049 if (ilHead.usVersion != 0x101) /* probably version? */ 2050 return NULL; 2051 2052 #if 0 2053 FIXME(" ilHead.cCurImage = %d\n",ilHead.cCurImage); 2054 FIXME(" ilHead.cMaxImage = %d\n",ilHead.cMaxImage); 2055 FIXME(" ilHead.cGrow = %d\n",ilHead.cGrow); 2056 FIXME(" ilHead.cx = %d\n",ilHead.cx); 2057 FIXME(" ilHead.cy = %d\n",ilHead.cy); 2058 FIXME(" ilHead.flags = %x\n",ilHead.flags); 2059 FIXME(" ilHead.ovls[0] = %d\n",ilHead.ovls[0]); 2060 FIXME(" ilHead.ovls[1] = %d\n",ilHead.ovls[1]); 2061 FIXME(" ilHead.ovls[2] = %d\n",ilHead.ovls[2]); 2062 FIXME(" ilHead.ovls[3] = %d\n",ilHead.ovls[3]); 2063 #endif 2064 2065 hbmColor = _read_bitmap(pstm,ilHead.flags & ~ILC_MASK,ilHead.cx,ilHead.cy); 2066 if (!hbmColor) 2067 return NULL; 2068 if (ilHead.flags & ILC_MASK) { 2069 hbmMask = _read_bitmap(pstm,0,ilHead.cx,ilHead.cy); 2070 if (!hbmMask) { 2071 DeleteObject(hbmColor); 2072 return NULL; 2073 } 2074 } 2075 2076 himl = ImageList_Create ( 2077 ilHead.cx, 2078 ilHead.cy, 2079 ilHead.flags, 2080 1, /* initial */ 2081 ilHead.cGrow 2082 ); 2083 if (!himl) { 2084 DeleteObject(hbmColor); 2085 DeleteObject(hbmMask); 2086 return NULL; 2087 } 2088 himl->hbmImage = hbmColor; 2089 himl->hbmMask = hbmMask; 2090 himl->cCurImage = ilHead.cCurImage; 2091 himl->cMaxImage = ilHead.cMaxImage; 2092 2093 ImageList_SetBkColor(himl,ilHead.bkcolor); 2094 for (i=0;i<4;i++) 2095 ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1); 2096 return himl; 1931 2097 } 1932 2098 … … 2484 2650 if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE)) 2485 2651 return FALSE; 2486 if ((iImage < 0) || (iImage > himl->cCurImage)) 2487 return FALSE; 2488 2652 if ((iImage != -1) && ((iImage < 0) || (iImage > himl->cCurImage))) 2653 return FALSE; 2489 2654 himl->nOvlIdx[iOverlay - 1] = iImage; 2490 2655 return TRUE;
Note:
See TracChangeset
for help on using the changeset viewer.