Changeset 1966 for trunk/src/gdi32/gdi32.cpp
- Timestamp:
- Dec 4, 1999, 2:53:14 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/gdi32.cpp
r1961 r1966 1 /* $Id: gdi32.cpp,v 1.2 2 1999-12-03 17:31:49 cbratschiExp $ */1 /* $Id: gdi32.cpp,v 1.23 1999-12-04 13:53:12 hugh Exp $ */ 2 2 3 3 /* … … 149 149 //****************************************************************************** 150 150 //****************************************************************************** 151 152 static hFntDefaultGui = NULL; 151 153 HGDIOBJ WIN32API GetStockObject(int arg1) 152 154 { 153 155 HGDIOBJ obj; 154 156 155 switch(arg1) { 157 switch(arg1) 158 { 156 159 case DEFAULT_GUI_FONT: 157 obj = NULL; 160 if(NULL==hFntDefaultGui) 161 hFntDefaultGui = CreateFontA( 0, 0, 0, 0, FW_MEDIUM, FALSE, 162 FALSE, FALSE, ANSI_CHARSET, 163 OUT_DEFAULT_PRECIS, 164 CLIP_DEFAULT_PRECIS, 165 DEFAULT_QUALITY, 166 FIXED_PITCH|FF_MODERN, "WarpSans"); 167 obj = hFntDefaultGui; 158 168 break; 159 169 default: … … 168 178 UINT WIN32API RealizePalette( HDC arg1) 169 179 { 170 dprintf(("GDI32: RealizePalette \n"));180 dprintf(("GDI32: RealizePalette(0x%08X)\n",arg1)); 171 181 return O32_RealizePalette(arg1); 172 182 } … … 176 186 { 177 187 178 if(DIBSection::getSection() != NULL) 188 if(DIBSection::getSection() != NULL) 189 { 190 DIBSection *dsect = DIBSection::find(arg1); 191 if(dsect) 179 192 { 180 DIBSection *dsect = DIBSection::find(arg1); 181 if(dsect) 182 { 183 return dsect->GetDIBSection(arg2, (DIBSECTION*)arg3); 184 } 193 return dsect->GetDIBSection(arg2, (DIBSECTION*)arg3); 185 194 } 186 187 dprintf(("GDI32: GetObject %X %X %X\n", arg1, arg2, arg3)); 188 return O32_GetObject(arg1, arg2, arg3); 195 } 196 197 dprintf(("GDI32: GetObject %X %X %X\n", arg1, arg2, arg3)); 198 return O32_GetObject(arg1, arg2, arg3); 189 199 } 190 200 //****************************************************************************** … … 214 224 HPALETTE WIN32API CreatePalette( const LOGPALETTE * arg1) 215 225 { 226 HPALETTE rc; 216 227 dprintf(("GDI32: CreatePalette\n")); 217 return O32_CreatePalette(arg1); 228 for(int i=0; i<arg1->palNumEntries;i++) 229 { 230 dprintf2(("Index %d : 0x%08X\n",i, *((DWORD*)(&arg1->palPalEntry[i])) )); 231 } 232 rc = O32_CreatePalette(arg1); 233 dprintf((" returns 0x%08X\n",rc)); 234 235 return rc; 218 236 } 219 237 //****************************************************************************** … … 266 284 HBITMAP WIN32API CreateDIBitmap(HDC arg1, const BITMAPINFOHEADER * arg2, DWORD arg3, const void * arg4, const BITMAPINFO * arg5, UINT arg6) 267 285 { 286 int iHeight; 287 HBITMAP rc; 268 288 dprintf(("GDI32: CreateDIBitmap\n")); 269 //TEMPORARY HACK TO PREVENT CRASH IN OPEN32 (WSeB GA) 270 if(arg2->biHeight < 0) { 271 ((BITMAPINFOHEADER *)arg2)->biHeight = -arg2->biHeight; 289 290 //TEMPORARY HACK TO PREVENT CRASH IN OPEN32 (WSeB GA) 291 292 iHeight = arg2->biHeight; 293 if(arg2->biHeight < 0) 294 { 295 ((BITMAPINFOHEADER *)arg2)->biHeight = -arg2->biHeight; 272 296 } 273 return O32_CreateDIBitmap(arg1, arg2, arg3, arg4, arg5, arg6); 297 298 rc = O32_CreateDIBitmap(arg1, arg2, arg3, arg4, arg5, arg6); 299 300 ((BITMAPINFOHEADER *)arg2)->biHeight = iHeight; 301 302 return rc; 274 303 } 275 304 //****************************************************************************** … … 378 407 int WIN32API SetStretchBltMode( HDC arg1, int arg2) 379 408 { 380 dprintf(("GDI32: SetStretchBltMode %X, %x\n",arg1, arg2));409 dprintf(("GDI32: SetStretchBltMode 0x%08X, 0x%08X\n",arg1, arg2)); 381 410 382 411 if(DIBSection::getSection() != NULL) … … 398 427 //// dprintf(("GDI32: SelectObject\n")); 399 428 400 if(DIBSection::getSection() != NULL) { 401 DIBSection *dsect; 402 403 dsect = DIBSection::find(hdc); 404 if(dsect) {//remove previously selected dibsection 405 dsect->UnSelectDIBObject(); 406 } 407 dsect = DIBSection::find((DWORD)hObj); 408 if(dsect) { 409 dsect->SelectDIBObject(hdc); 410 } 429 if(DIBSection::getSection() != NULL) 430 { 431 DIBSection *dsect; 432 433 dsect = DIBSection::find(hdc); 434 if(dsect) 435 { 436 //remove previously selected dibsection 437 dsect->UnSelectDIBObject(); 438 } 439 dsect = DIBSection::find((DWORD)hObj); 440 if(dsect) 441 { 442 dsect->SelectDIBObject(hdc); 443 } 411 444 } 412 445 rc = O32_SelectObject(hdc, hObj); 413 if(rc != 0 && DIBSection::getSection != NULL) { 414 DIBSection *dsect = DIBSection::find((DWORD)rc); 415 if(dsect) { 416 dsect->UnSelectDIBObject(); 417 } 446 if(rc != 0 && DIBSection::getSection != NULL) 447 { 448 DIBSection *dsect = DIBSection::find((DWORD)rc); 449 if(dsect) 450 { 451 dsect->UnSelectDIBObject(); 452 } 418 453 } 419 454 return(rc); … … 423 458 HPALETTE WIN32API SelectPalette(HDC arg1, HPALETTE arg2, BOOL arg3) 424 459 { 425 dprintf(("GDI32: SelectPalette %x", arg1)); 426 return O32_SelectPalette(arg1, arg2, arg3); 460 dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)\n", arg1, arg2, arg3)); 461 if(DIBSection::getSection() != NULL) 462 { 463 DIBSection *dsect = DIBSection::findHDC(arg1); 464 if(dsect) 465 { 466 PALETTEENTRY Pal[256]; 467 char PalSize = dsect->GetBitCount(); 468 dprintf((" - Set Palette Values in DIBSection\n")); 469 if(PalSize<=8) 470 { 471 GetPaletteEntries( arg2, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal); 472 dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal); 473 } 474 475 } 476 } 477 return O32_SelectPalette(arg1, arg2, arg3); 427 478 } 428 479 //****************************************************************************** … … 651 702 char *astring2 = UnicodeToAsciiString((LPWSTR)arg2); 652 703 char *astring3 = UnicodeToAsciiString((LPWSTR)arg3); 704 653 705 if(arg4) 654 706 { … … 697 749 devmode.dmReserved1 = arg4->dmReserved1; 698 750 devmode.dmReserved2 = arg4->dmReserved2; 699 700 751 rc = O32_CreateDC(astring1,astring2,astring3,&devmode); 701 752 } … … 706 757 FreeAsciiString(astring2); 707 758 FreeAsciiString(astring3); 759 708 760 if(arg4) 709 761 { … … 739 791 HENHMETAFILE WIN32API CreateEnhMetaFileW( HDC arg1, LPCWSTR arg2, const RECT * arg3, LPCWSTR arg4) 740 792 { 741 dprintf(("GDI32: CreateEnhMetaFileW STUB")); 742 // NOTE: This will not work as is (needs UNICODE support) 743 // return O32_CreateEnhMetaFile(arg1, arg2, arg3, arg4); 744 return 0; 793 char *astring1 = UnicodeToAsciiString((LPWSTR)arg2); 794 char *astring2 = UnicodeToAsciiString((LPWSTR)arg4); 795 HENHMETAFILE rc; 796 797 dprintf(("GDI32: CreateMetaFileW")); 798 rc = O32_CreateEnhMetaFile(arg1,astring1,arg3,astring2); 799 FreeAsciiString(astring1); 800 FreeAsciiString(astring2); 801 return rc; 745 802 } 746 803 //****************************************************************************** … … 1322 1379 UINT WIN32API GetNearestPaletteIndex( HPALETTE arg1, COLORREF arg2) 1323 1380 { 1324 dprintf(("GDI32: GetNearestPaletteIndex\n")); 1325 return O32_GetNearestPaletteIndex(arg1, arg2); 1381 UINT rc; 1382 dprintf(("GDI32: GetNearestPaletteIndex (0x%08X ,0x%08X) ",arg1,arg2)); 1383 rc = O32_GetNearestPaletteIndex(arg1, arg2); 1384 dprintf(("Returns %d\n",rc)); 1385 return rc; 1326 1386 } 1327 1387 //****************************************************************************** … … 2108 2168 //****************************************************************************** 2109 2169 //WINE: OBJECTS\DIB.C 2110 //****************************************************************************** 2111 HBITMAP WIN32API CreateDIBSection( HDC hdc, BITMAPINFO *pbmi, UINT iUsage,2112 2170 //********************************************************************************* 2171 HBITMAP WIN32API CreateDIBSection( HDC hdc, BITMAPINFO *pbmi, UINT iUsage, 2172 VOID **ppvBits, HANDLE hSection, DWORD dwOffset) 2113 2173 { 2114 2174 HBITMAP res = 0; 2115 2175 BOOL fFlip = 0; 2176 int iHeight, iWidth; 2116 2177 2117 2178 dprintf(("GDI32: CreateDIBSection %x %x %x %d", hdc, iUsage, hSection, dwOffset)); 2118 if(hSection) { 2119 dprintf(("GDI32: CreateDIBSection, hSection != NULL, not supported!\n")); 2120 return NULL; 2179 if(hSection) 2180 { 2181 dprintf(("GDI32: CreateDIBSection, hSection != NULL, not supported!\n")); 2182 return NULL; 2121 2183 } 2122 2184 2123 2185 //SvL: 13-9-98: StarCraft uses bitmap with negative height 2124 if(pbmi->bmiHeader.biWidth < 0) { 2125 pbmi->bmiHeader.biWidth = -pbmi->bmiHeader.biWidth; 2126 fFlip = FLIP_HOR; 2186 iWidth = pbmi->bmiHeader.biWidth; 2187 if(pbmi->bmiHeader.biWidth < 0) 2188 { 2189 pbmi->bmiHeader.biWidth = -pbmi->bmiHeader.biWidth; 2190 fFlip = FLIP_HOR; 2127 2191 } 2128 if(pbmi->bmiHeader.biHeight < 0) { 2129 pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight; 2130 fFlip |= FLIP_VERT; 2192 iHeight = pbmi->bmiHeader.biHeight; 2193 if(pbmi->bmiHeader.biHeight < 0) 2194 { 2195 pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight; 2196 fFlip |= FLIP_VERT; 2131 2197 } 2132 2198 … … 2134 2200 if (res) 2135 2201 { 2136 DIBSection *dsect = new DIBSection((WINBITMAPINFOHEADER *)&pbmi->bmiHeader, (DWORD)res, fFlip); 2137 dprintf(("Constructor returned\n",res)); 2138 if(ppvBits!=NULL) 2139 *ppvBits = dsect->GetDIBObject(); 2140 dprintf(("GDI32: return %08X\n",res)); 2141 return(res); 2202 ULONG Pal[256]; 2203 char PalSize; 2204 LOGPALETTE tmpPal = { 0x300,1,{0,0,0,0}}; 2205 HPALETTE hpalCur, hpalTmp; 2206 DIBSection *dsect = new DIBSection((WINBITMAPINFOHEADER *)&pbmi->bmiHeader, (DWORD)res, fFlip); 2207 dprintf(("Constructor returned\n")); 2208 2209 if(NULL!=dsect) 2210 { 2211 PalSize = dsect->GetBitCount(); 2212 if(PalSize<=8) 2213 { 2214 // Now get the current Palette from the DC 2215 hpalTmp = CreatePalette(&tmpPal); 2216 hpalCur = SelectPalette(hdc, hpalTmp, FALSE); 2217 2218 // and use it to set the DIBColorTable 2219 GetPaletteEntries( hpalCur, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal); 2220 dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal); 2221 2222 // Restore the DC Palette 2223 SelectPalette(hdc,hpalCur,FALSE); 2224 DeleteObject(hpalTmp); 2225 } 2226 // Set the hdc in the DIBSection so we can update the palete if a new 2227 // Paletet etc. gets selected into the DC. 2228 2229 dsect->SelectDIBObject(hdc); 2230 2231 if(ppvBits!=NULL) 2232 *ppvBits = dsect->GetDIBObject(); 2233 2234 pbmi->bmiHeader.biWidth = iWidth; 2235 pbmi->bmiHeader.biHeight = iHeight; 2236 2237 dprintf(("GDI32: return %08X\n",res)); 2238 return(res); 2239 } 2142 2240 } 2143 2241 2144 2242 /* Error. */ 2145 if (res) DeleteObject(res); 2243 if (res) 2244 DeleteObject(res); 2146 2245 *ppvBits = NULL; 2147 2246 #ifdef DEBUG … … 2156 2255 //****************************************************************************** 2157 2256 //****************************************************************************** 2158 UINT WIN32API GetDIBColorTable( HDC hdc, UINT uStartIndex, UINT cEntries,2257 UINT WIN32API GetDIBColorTable( HDC hdc, UINT uStartIndex, UINT cEntries, 2159 2258 RGBQUAD *pColors) 2160 2259 { … … 2188 2287 2189 2288 dprintf(("GDI32: SetDIBColorTable\n")); 2190 if(dsect) { 2191 return(dsect->SetDIBColorTable(uStartIndex, cEntries, pColors)); 2289 if(dsect) 2290 { 2291 return(dsect->SetDIBColorTable(uStartIndex, cEntries, pColors)); 2192 2292 } 2193 else return(0); 2293 else 2294 return(0); 2194 2295 } 2195 2296 //****************************************************************************** … … 2572 2673 * Result : TRUE / FALSE 2573 2674 * Remark : 2574 * Status : UNTESTED STUB2675 * Status : UNTESTED 2575 2676 * 2576 2677 * Author : Patrick Haller [Mon, 1998/06/15 08:00] 2678 * Markus Montkowski [Wen, 1999/01/12 20:18] 2577 2679 *****************************************************************************/ 2578 2680 … … 2581 2683 CONST XFORM *lLPXFORM2) 2582 2684 { 2583 dprintf(("GDI32: CombineTransform(%08xh,%08xh,%08xh) not implemented.\n",2685 dprintf(("GDI32: CombineTransform(%08xh,%08xh,%08xh).\n", 2584 2686 lLPXFORMResult, 2585 2687 lLPXFORM1, 2586 2688 lLPXFORM2)); 2587 2689 2690 XFORM xfrm; 2691 if( O32_IsBadWritePtr( (void*)lLPXFORMResult, sizeof(XFORM)) || 2692 O32_IsBadReadPtr( (void*)lLPXFORM1, sizeof(XFORM)) || 2693 O32_IsBadWritePtr( (void*)lLPXFORM2, sizeof(XFORM)) ) 2588 2694 return (FALSE); 2695 2696 // Add the translations 2697 lLPXFORMResult->eDx = lLPXFORM1->eDx + lLPXFORM2->eDx; 2698 lLPXFORMResult->eDy = lLPXFORM1->eDy + lLPXFORM2->eDy; 2699 2700 // Multiply the matrixes 2701 xfrm.eM11 = lLPXFORM1->eM11 * lLPXFORM2->eM11 + lLPXFORM1->eM21 * lLPXFORM1->eM12; 2702 xfrm.eM12 = lLPXFORM1->eM11 * lLPXFORM2->eM12 + lLPXFORM1->eM12 * lLPXFORM1->eM22; 2703 xfrm.eM21 = lLPXFORM1->eM21 * lLPXFORM2->eM11 + lLPXFORM1->eM22 * lLPXFORM1->eM21; 2704 xfrm.eM22 = lLPXFORM1->eM21 * lLPXFORM2->eM12 + lLPXFORM1->eM22 * lLPXFORM1->eM22; 2705 2706 // Now copy to resulting XFROM as the pt must not be distinct 2707 lLPXFORMResult->eM11 = xfrm.eM11; 2708 lLPXFORMResult->eM12 = xfrm.eM12; 2709 lLPXFORMResult->eM21 = xfrm.eM21; 2710 lLPXFORMResult->eM22 = xfrm.eM22; 2711 2712 return (TRUE); 2589 2713 } 2590 2714
Note:
See TracChangeset
for help on using the changeset viewer.