1769 |
1785 |
1770 %{ /* NOCONTEXT */ |
1786 %{ /* NOCONTEXT */ |
1771 if (__isExternalAddressLike(aDC) |
1787 if (__isExternalAddressLike(aDC) |
1772 && __bothSmallInteger(x0, y0) |
1788 && __bothSmallInteger(x0, y0) |
1773 && __bothSmallInteger(x1, y1)) { |
1789 && __bothSmallInteger(x1, y1)) { |
1774 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1790 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1775 COLORREF fgColor; |
1791 COLORREF fgColor; |
1776 HANDLE prevPen, hPen; |
1792 HANDLE prevPen, hPen; |
1777 int __x1 = __intVal(x1), __y1 = __intVal(y1); |
1793 int __x1 = __intVal(x1), __y1 = __intVal(y1); |
1778 int lStyleSymbol, lStyleInt; |
1794 OBJ lStyleSymbol; |
1779 int lw; |
1795 int lStyleInt; |
|
1796 int lw; |
1780 |
1797 |
1781 /* DPRINTF(("displayLine: %d/%d -> %d/%d\n", |
1798 /* DPRINTF(("displayLine: %d/%d -> %d/%d\n", |
1782 __intVal(x0), __intVal(y0), |
1799 __intVal(x0), __intVal(y0), |
1783 __x1, __y1)); |
1800 __x1, __y1)); |
1784 */ |
1801 */ |
1785 |
1802 |
1786 lw= __intVal(__INST(lineWidth)); |
1803 lw= __intVal(__INST(lineWidth)); |
1787 lStyleSymbol= __INST(lineStyle); |
1804 lStyleSymbol= __INST(lineStyle); |
1788 |
1805 |
1789 /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
1806 /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
1790 only works with lineWidth = 1 */ |
1807 only works with lineWidth = 1 */ |
1791 |
1808 |
1792 if (lStyleSymbol == @symbol(solid)) { |
1809 if (lStyleSymbol == @symbol(solid)) { |
1793 lStyleInt= PS_SOLID; |
1810 lStyleInt= PS_SOLID; |
1794 } else if (lStyleSymbol == @symbol(dashed)) { |
1811 } else if (lStyleSymbol == @symbol(dashed)) { |
1795 lStyleInt= PS_DASH; |
1812 lStyleInt= PS_DASH; |
1796 } else if (lStyleSymbol == @symbol(dotted)) { |
1813 } else if (lStyleSymbol == @symbol(dotted)) { |
1797 lStyleInt= PS_DOT; |
1814 lStyleInt= PS_DOT; |
1798 } else if (lStyleSymbol == @symbol(dashDot)) { |
1815 } else if (lStyleSymbol == @symbol(dashDot)) { |
1799 lStyleInt= PS_DASHDOT; |
1816 lStyleInt= PS_DASHDOT; |
1800 } else if (lStyleSymbol == @symbol(dashDotDot)) { |
1817 } else if (lStyleSymbol == @symbol(dashDotDot)) { |
1801 lStyleInt= PS_DASHDOTDOT; |
1818 lStyleInt= PS_DASHDOTDOT; |
1802 } else if (lStyleSymbol == @symbol(insideFrame)) { |
1819 } else if (lStyleSymbol == @symbol(insideFrame)) { |
1803 lStyleInt= PS_INSIDEFRAME; |
1820 lStyleInt= PS_INSIDEFRAME; |
1804 } else |
1821 } else |
1805 lStyleInt= PS_SOLID; |
1822 lStyleInt= PS_SOLID; |
1806 |
1823 |
1807 fgColor = GetTextColor(hDC); |
1824 fgColor = GetTextColor(hDC); |
1808 hPen = CreatePen(lStyleInt, lw, fgColor); |
1825 hPen = CreatePen(lStyleInt, lw, fgColor); |
1809 prevPen = SelectObject(hDC, hPen); |
1826 prevPen = SelectObject(hDC, hPen); |
1810 MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL); |
1827 MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL); |
1811 LineTo(hDC, __x1, __y1); |
1828 LineTo(hDC, __x1, __y1); |
1812 /* |
1829 /* |
1813 * end-point ... |
1830 * end-point ... |
1814 */ |
1831 */ |
1815 // LineTo(hDC, __x1+1, __y1); |
1832 // LineTo(hDC, __x1+1, __y1); |
1816 |
1833 |
1817 SelectObject(hDC, prevPen); |
1834 SelectObject(hDC, prevPen); |
1818 DeleteObject(hPen); |
1835 DeleteObject(hPen); |
1819 |
1836 |
1820 RETURN ( self ); |
1837 RETURN ( self ); |
1821 } |
1838 } |
1822 %} |
1839 %} |
1823 ! |
1840 ! |
1824 |
1841 |
1825 displayPointX:px y:py in:ignoredDrawableId with:aDC |
1842 displayPointX:px y:py in:ignoredDrawableId with:aDC |
2039 int xL, yT; |
2057 int xL, yT; |
2040 if (__isExternalAddressLike(aDC) |
2058 if (__isExternalAddressLike(aDC) |
2041 && __bothSmallInteger(x, y) |
2059 && __bothSmallInteger(x, y) |
2042 && __bothSmallInteger(width, height)) { |
2060 && __bothSmallInteger(width, height)) { |
2043 |
2061 |
2044 xL = __intVal(x); |
2062 xL = __intVal(x); |
2045 yT = __intVal(y); |
2063 yT = __intVal(y); |
2046 w = __intVal(width); |
2064 w = __intVal(width); |
2047 h = __intVal(height); |
2065 h = __intVal(height); |
2048 |
2066 |
2049 DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h)); |
2067 DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h)); |
2050 |
2068 |
2051 if ((w >= 0) && (h >= 0)) { |
2069 if ((w >= 0) && (h >= 0)) { |
2052 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2070 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2053 COLORREF fgColor; |
2071 COLORREF fgColor; |
2054 HANDLE prevPen, hPen; |
2072 HANDLE prevPen, hPen; |
2055 int lStyleSymbol, lStyleInt; |
2073 OBJ lStyleSymbol; |
2056 |
2074 int lStyleInt; |
2057 int lw; |
2075 int lw; |
2058 |
2076 |
2059 lw= __intVal(__INST(lineWidth)); |
2077 lw= __intVal(__INST(lineWidth)); |
2060 lStyleSymbol= __INST(lineStyle); |
2078 lStyleSymbol= __INST(lineStyle); |
2061 |
2079 |
2062 /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
2080 /* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
2063 only works with lineWidth = 1 */ |
2081 only works with lineWidth = 1 */ |
2064 |
2082 |
2065 if (lStyleSymbol == @symbol(solid)) { |
2083 if (lStyleSymbol == @symbol(solid)) { |
2066 lStyleInt= PS_SOLID; |
2084 lStyleInt= PS_SOLID; |
2067 } else if (lStyleSymbol == @symbol(dashed)) { |
2085 } else if (lStyleSymbol == @symbol(dashed)) { |
2068 lStyleInt= PS_DASH; |
2086 lStyleInt= PS_DASH; |
2069 } else if (lStyleSymbol == @symbol(dotted)) { |
2087 } else if (lStyleSymbol == @symbol(dotted)) { |
2070 lStyleInt= PS_DOT; |
2088 lStyleInt= PS_DOT; |
2071 } else if (lStyleSymbol == @symbol(dashDot)) { |
2089 } else if (lStyleSymbol == @symbol(dashDot)) { |
2072 lStyleInt= PS_DASHDOT; |
2090 lStyleInt= PS_DASHDOT; |
2073 } else if (lStyleSymbol == @symbol(dashDotDot)) { |
2091 } else if (lStyleSymbol == @symbol(dashDotDot)) { |
2074 lStyleInt= PS_DASHDOTDOT; |
2092 lStyleInt= PS_DASHDOTDOT; |
2075 } else if (lStyleSymbol == @symbol(insideFrame)) { |
2093 } else if (lStyleSymbol == @symbol(insideFrame)) { |
2076 lStyleInt= PS_INSIDEFRAME; |
2094 lStyleInt= PS_INSIDEFRAME; |
2077 } else |
2095 } else |
2078 lStyleInt= PS_SOLID; |
2096 lStyleInt= PS_SOLID; |
2079 |
2097 |
2080 fgColor = GetTextColor(hDC); |
2098 fgColor = GetTextColor(hDC); |
2081 hPen = CreatePen(lStyleInt, lw, fgColor); |
2099 hPen = CreatePen(lStyleInt, lw, fgColor); |
2082 |
2100 |
2083 prevPen = SelectObject(hDC, hPen); |
2101 prevPen = SelectObject(hDC, hPen); |
2084 MoveToEx(hDC, xL, yT, NULL); |
2102 MoveToEx(hDC, xL, yT, NULL); |
2085 LineTo(hDC, xL+w, yT); // to top-right |
2103 LineTo(hDC, xL+w, yT); // to top-right |
2086 LineTo(hDC, xL+w, yT+h); // to bot-right |
2104 LineTo(hDC, xL+w, yT+h); // to bot-right |
2087 MoveToEx(hDC, xL, yT, NULL); // back to top-left |
2105 MoveToEx(hDC, xL, yT, NULL); // back to top-left |
2088 LineTo(hDC, xL, yT+h); // to bot-left |
2106 LineTo(hDC, xL, yT+h); // to bot-left |
2089 // LineTo(hDC, xL+w+1, yT+h); // move pen one pixel more |
2107 // LineTo(hDC, xL+w+1, yT+h); // move pen one pixel more |
2090 LineTo(hDC, xL+w, yT+h); // move pen one pixel more |
2108 LineTo(hDC, xL+w, yT+h); // move pen one pixel more |
2091 |
2109 |
2092 SelectObject(hDC, prevPen); |
2110 SelectObject(hDC, prevPen); |
2093 DeleteObject(hPen); |
2111 DeleteObject(hPen); |
2094 |
2112 |
2095 } |
2113 } |
2096 RETURN ( self ); |
2114 RETURN ( self ); |
2097 } |
2115 } |
2098 %}. |
2116 %}. |
2099 self primitiveFailed |
2117 self primitiveFailed |
2100 |
2118 |
2101 "Created: / 28-07-2006 / 20:18:25 / fm" |
2119 "Created: / 28-07-2006 / 20:18:25 / fm" |
2181 if (__isExternalAddressLike(aDC) |
2199 if (__isExternalAddressLike(aDC) |
2182 && __isNonNilObject(aString) |
2200 && __isNonNilObject(aString) |
2183 && __bothSmallInteger(index1, index2) |
2201 && __bothSmallInteger(index1, index2) |
2184 && __bothSmallInteger(x, y)) |
2202 && __bothSmallInteger(x, y)) |
2185 { |
2203 { |
2186 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2204 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2187 int pX, pY; |
2205 int pX, pY; |
2188 COLORREF fgColor; |
2206 COLORREF fgColor; |
2189 |
2207 |
2190 pX = __intVal(x); |
2208 pX = __intVal(x); |
2191 pY = __intVal(y); |
2209 pY = __intVal(y); |
2192 |
2210 |
2193 if (opaque == true) { |
2211 if (opaque == true) { |
2194 SetBkMode(hDC, OPAQUE); |
2212 SetBkMode(hDC, OPAQUE); |
2195 } else { |
2213 } else { |
2196 SetBkMode(hDC, TRANSPARENT); |
2214 SetBkMode(hDC, TRANSPARENT); |
2197 } |
2215 } |
2198 fgColor = GetTextColor(hDC); |
2216 fgColor = GetTextColor(hDC); |
2199 SetTextColor(hDC, fgColor); |
2217 SetTextColor(hDC, fgColor); |
2200 SetBkColor(hDC, 0xFFFFFFFF); |
2218 SetBkColor(hDC, 0xFFFFFFFF); |
2201 |
2219 |
2202 cls = __qClass(aString); |
2220 cls = __qClass(aString); |
2203 |
2221 |
2204 i1 = __intVal(index1) - 1; |
2222 i1 = __intVal(index1) - 1; |
2205 if (i1 >= 0) { |
2223 if (i1 >= 0) { |
2206 i2 = __intVal(index2) - 1; |
2224 i2 = __intVal(index2) - 1; |
2207 if (i2 < i1) { |
2225 if (i2 < i1) { |
2208 goto ret; |
2226 goto ret; |
2209 } |
2227 } |
2210 |
2228 |
2211 cp = _stringVal(aString); |
2229 cp = _stringVal(aString); |
2212 l = i2 - i1 + 1; |
2230 l = i2 - i1 + 1; |
2213 |
2231 |
2214 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2232 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2215 n = _stringSize(aString); |
2233 n = _stringSize(aString); |
2216 if (i2 < n) { |
2234 if (i2 < n) { |
2217 cp += i1; |
2235 cp += i1; |
2218 DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC)); |
2236 DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC)); |
2219 |
2237 |
2220 if (l > 32767) { |
2238 if (l > 32767) { |
2221 l = 32767; |
2239 l = 32767; |
2222 } |
2240 } |
2223 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2241 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2224 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2242 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2225 } |
2243 } |
2226 goto ret; |
2244 goto ret; |
2227 } |
2245 } |
2228 } |
2246 } |
2229 |
2247 |
2230 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2248 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2231 cp += nInstBytes; |
2249 cp += nInstBytes; |
2232 n = __byteArraySize(aString) - nInstBytes; |
2250 n = __byteArraySize(aString) - nInstBytes; |
2233 |
2251 |
2234 if (__isBytes(aString)) { |
2252 if (__isBytes(aString)) { |
2235 if (i2 < n) { |
2253 if (i2 < n) { |
2236 cp += i1; |
2254 cp += i1; |
2237 DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
2255 DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
2238 if (l > 32767) { |
2256 if (l > 32767) { |
2239 l = 32767; |
2257 l = 32767; |
2240 } |
2258 } |
2241 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2259 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2242 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2260 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2243 } |
2261 } |
2244 goto ret; |
2262 goto ret; |
2245 } |
2263 } |
2246 } |
2264 } |
2247 |
2265 |
2248 /* Unicode */ |
2266 /* Unicode */ |
2249 if (__isWords(aString)) { |
2267 if (__isWords(aString)) { |
2250 n = n / 2; |
2268 n = n / 2; |
2251 if (i2 < n) { |
2269 if (i2 < n) { |
2252 WIDECHAR *w_cp = (WIDECHAR *)cp; |
2270 WIDECHAR *w_cp = (WIDECHAR *)cp; |
2253 |
2271 |
2254 w_cp += i1; |
2272 w_cp += i1; |
2255 |
2273 |
2256 if (! TextOutW(hDC, pX, pY, w_cp, l)) { |
2274 if (! TextOutW(hDC, pX, pY, w_cp, l)) { |
2257 DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError())); |
2275 DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError())); |
2258 } |
2276 } |
2259 goto ret; |
2277 goto ret; |
2260 } |
2278 } |
2261 } |
2279 } |
2262 } |
2280 } |
2263 ret: |
2281 ret: |
2264 RETURN ( self ); |
2282 RETURN ( self ); |
2265 } |
2283 } |
2266 %}. |
2284 %}. |
2267 self primitiveFailed |
2285 self primitiveFailed |
2268 |
2286 |
2269 "Created: / 28-07-2006 / 20:35:19 / fm" |
2287 "Created: / 28-07-2006 / 20:35:19 / fm" |
2283 if (__isExternalAddressLike(aDC) |
2301 if (__isExternalAddressLike(aDC) |
2284 && __isNonNilObject(aString) |
2302 && __isNonNilObject(aString) |
2285 && __bothSmallInteger(index1, index2) |
2303 && __bothSmallInteger(index1, index2) |
2286 && __bothSmallInteger(x, y)) |
2304 && __bothSmallInteger(x, y)) |
2287 { |
2305 { |
2288 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2306 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2289 int pX, pY; |
2307 int pX, pY; |
2290 COLORREF fgColor; |
2308 COLORREF fgColor; |
2291 |
2309 |
2292 pX = __intVal(x); |
2310 pX = __intVal(x); |
2293 pY = __intVal(y); |
2311 pY = __intVal(y); |
2294 pY -= __intVal(fontAscent); |
2312 pY -= __intVal(fontAscent); |
2295 |
2313 |
2296 if (opaque == true) { |
2314 if (opaque == true) { |
2297 SetBkMode(hDC, OPAQUE); |
2315 SetBkMode(hDC, OPAQUE); |
2298 } else { |
2316 } else { |
2299 SetBkMode(hDC, TRANSPARENT); |
2317 SetBkMode(hDC, TRANSPARENT); |
2300 } |
2318 } |
2301 fgColor = GetTextColor(hDC); |
2319 fgColor = GetTextColor(hDC); |
2302 SetTextColor(hDC, fgColor); |
2320 SetTextColor(hDC, fgColor); |
2303 SetBkColor(hDC, 0xFFFFFFFF); |
2321 SetBkColor(hDC, 0xFFFFFFFF); |
2304 |
2322 |
2305 cls = __qClass(aString); |
2323 cls = __qClass(aString); |
2306 |
2324 |
2307 i1 = __intVal(index1) - 1; |
2325 i1 = __intVal(index1) - 1; |
2308 if (i1 >= 0) { |
2326 if (i1 >= 0) { |
2309 i2 = __intVal(index2) - 1; |
2327 i2 = __intVal(index2) - 1; |
2310 if (i2 < i1) { |
2328 if (i2 < i1) { |
2311 goto ret; |
2329 goto ret; |
2312 } |
2330 } |
2313 |
2331 |
2314 cp = _stringVal(aString); |
2332 cp = _stringVal(aString); |
2315 l = i2 - i1 + 1; |
2333 l = i2 - i1 + 1; |
2316 |
2334 |
2317 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2335 if ((cls == @global(String)) || (cls == @global(Symbol))) { |
2318 n = _stringSize(aString); |
2336 n = _stringSize(aString); |
2319 if (i2 < n) { |
2337 if (i2 < n) { |
2320 cp += i1; |
2338 cp += i1; |
2321 DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC)); |
2339 DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC)); |
2322 |
2340 |
2323 if (l > 32767) { |
2341 if (l > 32767) { |
2324 l = 32767; |
2342 l = 32767; |
2325 } |
2343 } |
2326 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2344 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2327 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2345 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2328 } |
2346 } |
2329 goto ret; |
2347 goto ret; |
2330 } |
2348 } |
2331 } |
2349 } |
2332 |
2350 |
2333 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2351 nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
2334 cp += nInstBytes; |
2352 cp += nInstBytes; |
2335 n = __byteArraySize(aString) - nInstBytes; |
2353 n = __byteArraySize(aString) - nInstBytes; |
2336 |
2354 |
2337 if (__isBytes(aString)) { |
2355 if (__isBytes(aString)) { |
2338 if (i2 < n) { |
2356 if (i2 < n) { |
2339 cp += i1; |
2357 cp += i1; |
2340 DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
2358 DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
2341 if (l > 32767) { |
2359 if (l > 32767) { |
2342 l = 32767; |
2360 l = 32767; |
2343 } |
2361 } |
2344 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2362 if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
2345 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2363 DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
2346 } |
2364 } |
2347 goto ret; |
2365 goto ret; |
2348 } |
2366 } |
2349 } |
2367 } |
2350 |
2368 |
2351 /* Unicode */ |
2369 /* Unicode */ |
2352 if (__isWords(aString)) { |
2370 if (__isWords(aString)) { |
2353 n = n / 2; |
2371 n = n / 2; |
2354 if (i2 < n) { |
2372 if (i2 < n) { |
2355 WIDECHAR *w_cp = (WIDECHAR *)cp; |
2373 WIDECHAR *w_cp = (WIDECHAR *)cp; |
2356 |
2374 |
2357 w_cp += i1; |
2375 w_cp += i1; |
2358 |
2376 |
2359 if (! TextOutW(hDC, pX, pY, w_cp, l)) { |
2377 if (! TextOutW(hDC, pX, pY, w_cp, l)) { |
2360 DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError())); |
2378 DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError())); |
2361 } |
2379 } |
2362 goto ret; |
2380 goto ret; |
2363 } |
2381 } |
2364 } |
2382 } |
2365 } |
2383 } |
2366 ret: |
2384 ret: |
2367 RETURN ( self ); |
2385 RETURN ( self ); |
2368 } |
2386 } |
2369 %}. |
2387 %}. |
2370 self primitiveFailed |
2388 self primitiveFailed |
2371 |
2389 |
2372 "Created: / 28-07-2006 / 20:35:19 / fm" |
2390 "Created: / 28-07-2006 / 20:35:19 / fm" |
2410 %{ |
2428 %{ |
2411 int __x, __y, w, h; |
2429 int __x, __y, w, h; |
2412 float angle1, angle2; |
2430 float angle1, angle2; |
2413 |
2431 |
2414 if (__isSmallInteger(startAngle)) |
2432 if (__isSmallInteger(startAngle)) |
2415 angle1 = (float)(__intVal(startAngle)); |
2433 angle1 = (float)(__intVal(startAngle)); |
2416 else if (__isFloat(startAngle)) { |
2434 else if (__isFloat(startAngle)) { |
2417 angle1 = __floatVal(startAngle); |
2435 angle1 = __floatVal(startAngle); |
2418 } else if (__isShortFloat(startAngle)) { |
2436 } else if (__isShortFloat(startAngle)) { |
2419 angle1 = __shortFloatVal(startAngle); |
2437 angle1 = __shortFloatVal(startAngle); |
2420 } else goto bad; |
2438 } else goto bad; |
2421 |
2439 |
2422 if (__isSmallInteger(angle)) |
2440 if (__isSmallInteger(angle)) |
2423 angle2 = (float)(__intVal(angle)); |
2441 angle2 = (float)(__intVal(angle)); |
2424 else if (__isFloat(angle)) { |
2442 else if (__isFloat(angle)) { |
2425 angle2 = __floatVal(angle); |
2443 angle2 = __floatVal(angle); |
2426 } else if (__isShortFloat(angle)) { |
2444 } else if (__isShortFloat(angle)) { |
2427 angle2 = __shortFloatVal(angle); |
2445 angle2 = __shortFloatVal(angle); |
2428 } else goto bad; |
2446 } else goto bad; |
2429 |
2447 |
2430 if (angle2 <= 0) { |
2448 if (angle2 <= 0) { |
2431 RETURN (self); |
2449 RETURN (self); |
2432 } |
2450 } |
2433 |
2451 |
2434 if (__isExternalAddressLike(aDC) |
2452 if (__isExternalAddressLike(aDC) |
2435 && __bothSmallInteger(x, y) |
2453 && __bothSmallInteger(x, y) |
2436 && __bothSmallInteger(width, height)) |
2454 && __bothSmallInteger(width, height)) |
2437 { |
2455 { |
2438 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2456 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2439 HBRUSH hBrush, prevBrush; |
2457 HBRUSH hBrush, prevBrush; |
2440 HPEN prevPen = 0; |
2458 HPEN prevPen = 0; |
2441 COLORREF fgColor; |
2459 COLORREF fgColor; |
2442 int hatch, hasHatch; |
2460 int hatch, hasHatch; |
2443 |
2461 |
2444 w = __intVal(width); |
2462 w = __intVal(width); |
2445 h = __intVal(height); |
2463 h = __intVal(height); |
2446 __x = __intVal(x); |
2464 __x = __intVal(x); |
2447 __y = __intVal(y); |
2465 __y = __intVal(y); |
2448 |
2466 |
2449 fgColor = GetTextColor(hDC); |
2467 fgColor = GetTextColor(hDC); |
2450 |
2468 |
2451 hasHatch= 1; |
2469 hasHatch= 1; |
2452 |
2470 |
2453 if (hatchSymbol == @symbol(none)) { |
2471 if (hatchSymbol == @symbol(none)) { |
2454 hasHatch= 0; |
2472 hasHatch= 0; |
2455 } else if (hatchSymbol == @symbol(horizontal)) { |
2473 } else if (hatchSymbol == @symbol(horizontal)) { |
2456 hatch= HS_HORIZONTAL; |
2474 hatch= HS_HORIZONTAL; |
2457 } else if (hatchSymbol == @symbol(vertical)) { |
2475 } else if (hatchSymbol == @symbol(vertical)) { |
2458 hatch= HS_VERTICAL; |
2476 hatch= HS_VERTICAL; |
2459 } else if (hatchSymbol == @symbol(cross)) { |
2477 } else if (hatchSymbol == @symbol(cross)) { |
2460 hatch= HS_CROSS; |
2478 hatch= HS_CROSS; |
2461 } else if (hatchSymbol == @symbol(bDiagonal)) { |
2479 } else if (hatchSymbol == @symbol(bDiagonal)) { |
2462 hatch= HS_BDIAGONAL; |
2480 hatch= HS_BDIAGONAL; |
2463 } else if (hatchSymbol == @symbol(fDiagonal)) { |
2481 } else if (hatchSymbol == @symbol(fDiagonal)) { |
2464 hatch= HS_FDIAGONAL; |
2482 hatch= HS_FDIAGONAL; |
2465 } else if (hatchSymbol == @symbol(diagonalCross)) { |
2483 } else if (hatchSymbol == @symbol(diagonalCross)) { |
2466 hatch= HS_DIAGCROSS; |
2484 hatch= HS_DIAGCROSS; |
2467 } else |
2485 } else |
2468 hasHatch= 0; |
2486 hasHatch= 0; |
2469 |
2487 |
2470 if (hasHatch) { |
2488 if (hasHatch) { |
2471 hBrush = CreateHatchBrush(hatch, fgColor); |
2489 hBrush = CreateHatchBrush(hatch, fgColor); |
2472 } else { |
2490 } else { |
2473 hBrush = CreateSolidBrush(fgColor); |
2491 hBrush = CreateSolidBrush(fgColor); |
2474 } |
2492 } |
2475 |
2493 |
2476 prevBrush = SelectObject(hDC, hBrush); |
2494 prevBrush = SelectObject(hDC, hBrush); |
2477 if (hBrush == 0) { |
2495 if (hBrush == 0) { |
2478 DPRINTF(("fillArc: no brush\n")); |
2496 DPRINTF(("fillArc: no brush\n")); |
2479 } else { |
2497 } else { |
2480 HPEN hPen = 0; |
2498 HPEN hPen = 0; |
2481 |
2499 |
2482 if (0 /* __isWinNT */) { |
2500 if (0 /* __isWinNT */) { |
2483 fgColor = GetTextColor(hDC); |
2501 fgColor = GetTextColor(hDC); |
2484 hPen = CreatePen(PS_SOLID, 1, fgColor); |
2502 hPen = CreatePen(PS_SOLID, 1, fgColor); |
2485 prevPen = SelectObject(hDC, hPen); |
2503 prevPen = SelectObject(hDC, hPen); |
2486 if (hPen == 0) { |
2504 if (hPen == 0) { |
2487 DPRINTF(("fillArc: no pen\n")); |
2505 DPRINTF(("fillArc: no pen\n")); |
2488 goto failpen; |
2506 goto failpen; |
2489 } |
2507 } |
2490 } else { |
2508 } else { |
2491 prevPen = SelectObject(hDC, GetStockObject(NULL_PEN)); |
2509 prevPen = SelectObject(hDC, GetStockObject(NULL_PEN)); |
2492 w++; |
2510 w++; |
2493 h++; |
2511 h++; |
2494 } |
2512 } |
2495 |
2513 |
2496 { |
2514 { |
2497 double xB, yB, xE, yE, xR, yR; |
2515 double xB, yB, xE, yE, xR, yR; |
2498 |
2516 |
2499 xR = w / 2; |
2517 xR = w / 2; |
2500 yR = h / 2; |
2518 yR = h / 2; |
2501 if (angle2 - angle1 >= 360) { |
2519 if (angle2 - angle1 >= 360) { |
2502 xB = xE = __x + xR + 0.5; |
2520 xB = xE = __x + xR + 0.5; |
2503 yB = yE = __y /*+ yR + 0.5*/; |
2521 yB = yE = __y /*+ yR + 0.5*/; |
2504 } else { |
2522 } else { |
2505 double sin(), cos(); |
2523 double sin(), cos(); |
2506 float rad1, rad2; |
2524 float rad1, rad2; |
2507 |
2525 |
2508 if (angle1 <= 180) |
2526 if (angle1 <= 180) |
2509 angle1 = 180 - angle1; |
2527 angle1 = 180 - angle1; |
2510 else |
2528 else |
2511 angle1 = 360 + 180 - angle1; |
2529 angle1 = 360 + 180 - angle1; |
2512 angle2 = angle1 - angle2; |
2530 angle2 = angle1 - angle2; |
2513 /* sigh - compute the intersections ... */ |
2531 /* sigh - compute the intersections ... */ |
2514 rad1 = (angle1 * 3.14159265359) / 180.0; |
2532 rad1 = (angle1 * 3.14159265359) / 180.0; |
2515 rad2 = (angle2 * 3.14159265359) / 180.0; |
2533 rad2 = (angle2 * 3.14159265359) / 180.0; |
2516 xB = cos(rad1) * xR; |
2534 xB = cos(rad1) * xR; |
2517 yB = sin(rad1) * yR; |
2535 yB = sin(rad1) * yR; |
2518 xE = cos(rad2) * xR; |
2536 xE = cos(rad2) * xR; |
2519 yE = sin(rad2) * yR; |
2537 yE = sin(rad2) * yR; |
2520 xB = __x + xR - xB + 0.5; |
2538 xB = __x + xR - xB + 0.5; |
2521 yB = __y + yR - yB + 0.5; |
2539 yB = __y + yR - yB + 0.5; |
2522 xE = __x + xR - xE + 0.5; |
2540 xE = __x + xR - xE + 0.5; |
2523 yE = __y + yR - yE + 0.5; |
2541 yE = __y + yR - yE + 0.5; |
2524 } |
2542 } |
2525 DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2)); |
2543 DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2)); |
2526 |
2544 |
2527 Pie(hDC, |
2545 Pie(hDC, |
2528 __x, __y, |
2546 __x, __y, |
2529 __x + w + 1, __y + h + 1, |
2547 __x + w + 1, __y + h + 1, |
2530 (int)xB, (int)yB, |
2548 (int)xB, (int)yB, |
2531 (int)xE, (int)yE); |
2549 (int)xE, (int)yE); |
2532 |
2550 |
2533 if (hPen) { |
2551 if (hPen) { |
2534 DeleteObject(hPen); |
2552 DeleteObject(hPen); |
2535 } |
2553 } |
2536 } |
2554 } |
2537 failpen: |
2555 failpen: |
2538 if (prevPen) SelectObject(hDC, prevPen); |
2556 if (prevPen) SelectObject(hDC, prevPen); |
2539 DeleteObject(hPen); |
2557 DeleteObject(hPen); |
2540 |
2558 |
2541 SelectObject(hDC, prevBrush); |
2559 SelectObject(hDC, prevBrush); |
2542 DeleteObject(hBrush); |
2560 DeleteObject(hBrush); |
2543 } |
2561 } |
2544 RETURN ( self ); |
2562 RETURN ( self ); |
2545 } |
2563 } |
2546 bad: ; |
2564 bad: ; |
2547 %}. |
2565 %}. |
2548 self primitiveFailed |
2566 self primitiveFailed |
2549 ! |
2567 ! |
2571 |
2589 |
2572 int w, h; |
2590 int w, h; |
2573 if (__isExternalAddressLike(aDC) |
2591 if (__isExternalAddressLike(aDC) |
2574 && __bothSmallInteger(x, y) |
2592 && __bothSmallInteger(x, y) |
2575 && __bothSmallInteger(width, height)) { |
2593 && __bothSmallInteger(width, height)) { |
2576 w = __intVal(width); |
2594 w = __intVal(width); |
2577 h = __intVal(height); |
2595 h = __intVal(height); |
2578 |
2596 |
2579 if ((w >= 0) && (h >= 0)) { |
2597 if ((w >= 0) && (h >= 0)) { |
2580 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2598 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2581 HBRUSH hBrush, prevBrush; |
2599 HBRUSH hBrush, prevBrush; |
2582 RECT rct; |
2600 RECT rct; |
2583 COLORREF fgColor; |
2601 COLORREF fgColor; |
2584 int hatch, hasHatch; |
2602 int hatch, hasHatch; |
2585 |
2603 |
2586 fgColor = GetTextColor(hDC); |
2604 fgColor = GetTextColor(hDC); |
2587 hasHatch= 1; |
2605 hasHatch= 1; |
2588 |
2606 |
2589 if (hatchSymbol == @symbol(none)) { |
2607 if (hatchSymbol == @symbol(none)) { |
2590 hasHatch= 0; |
2608 hasHatch= 0; |
2591 } else if (hatchSymbol == @symbol(horizontal)) { |
2609 } else if (hatchSymbol == @symbol(horizontal)) { |
2592 hatch= HS_HORIZONTAL; |
2610 hatch= HS_HORIZONTAL; |
2593 } else if (hatchSymbol == @symbol(vertical)) { |
2611 } else if (hatchSymbol == @symbol(vertical)) { |
2594 hatch= HS_VERTICAL; |
2612 hatch= HS_VERTICAL; |
2595 } else if (hatchSymbol == @symbol(cross)) { |
2613 } else if (hatchSymbol == @symbol(cross)) { |
2596 hatch= HS_CROSS; |
2614 hatch= HS_CROSS; |
2597 } else if (hatchSymbol == @symbol(bDiagonal)) { |
2615 } else if (hatchSymbol == @symbol(bDiagonal)) { |
2598 hatch= HS_BDIAGONAL; |
2616 hatch= HS_BDIAGONAL; |
2599 } else if (hatchSymbol == @symbol(fDiagonal)) { |
2617 } else if (hatchSymbol == @symbol(fDiagonal)) { |
2600 hatch= HS_FDIAGONAL; |
2618 hatch= HS_FDIAGONAL; |
2601 } else if (hatchSymbol == @symbol(diagonalCross)) { |
2619 } else if (hatchSymbol == @symbol(diagonalCross)) { |
2602 hatch= HS_DIAGCROSS; |
2620 hatch= HS_DIAGCROSS; |
2603 } else |
2621 } else |
2604 hasHatch= 0; |
2622 hasHatch= 0; |
2605 |
2623 |
2606 if (hasHatch) { |
2624 if (hasHatch) { |
2607 hBrush = CreateHatchBrush(hatch, fgColor); |
2625 hBrush = CreateHatchBrush(hatch, fgColor); |
2608 } else { |
2626 } else { |
2609 hBrush = CreateSolidBrush(fgColor); |
2627 hBrush = CreateSolidBrush(fgColor); |
2610 } |
2628 } |
2611 |
2629 |
2612 rct.left = __intVal(x); |
2630 rct.left = __intVal(x); |
2613 rct.top = __intVal(y); |
2631 rct.top = __intVal(y); |
2614 rct.right = rct.left + w; // + 1; |
2632 rct.right = rct.left + w; // + 1; |
2615 rct.bottom = rct.top + h; // + 1; |
2633 rct.bottom = rct.top + h; // + 1; |
2616 |
2634 |
2617 prevBrush = SelectObject(hDC, hBrush); |
2635 prevBrush = SelectObject(hDC, hBrush); |
2618 FillRect(hDC, &rct, hBrush); |
2636 FillRect(hDC, &rct, hBrush); |
2619 SelectObject(hDC, prevBrush); |
2637 SelectObject(hDC, prevBrush); |
2620 DeleteObject(hBrush); |
2638 DeleteObject(hBrush); |
2621 |
2639 |
2622 } |
2640 } |
2623 } |
2641 } |
2624 RETURN ( self ); |
2642 RETURN ( self ); |
2625 |
2643 |
2626 |
2644 |
2627 %} |
2645 %} |
2637 OBJ point, px, py; |
2655 OBJ point, px, py; |
2638 int i, num; |
2656 int i, num; |
2639 |
2657 |
2640 if (__isExternalAddressLike(aDC) |
2658 if (__isExternalAddressLike(aDC) |
2641 && __isSmallInteger(numberOfPoints)) { |
2659 && __isSmallInteger(numberOfPoints)) { |
2642 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2660 HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2643 POINT p; |
2661 POINT p; |
2644 HBRUSH hBrush, prevBrush; |
2662 HBRUSH hBrush, prevBrush; |
2645 COLORREF fgColor; |
2663 COLORREF fgColor; |
2646 int hatch, hasHatch; |
2664 int hatch, hasHatch; |
2647 |
2665 |
2648 num = __intVal(numberOfPoints); |
2666 num = __intVal(numberOfPoints); |
2649 if (num < 3) { |
2667 if (num < 3) { |
2650 RETURN ( self ); |
2668 RETURN ( self ); |
2651 } |
2669 } |
2652 for (i=0; i<num; i++) { |
2670 for (i=0; i<num; i++) { |
2653 point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
2671 point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
2654 if (! __isPoint(point)) goto fail; |
2672 if (! __isPoint(point)) goto fail; |
2655 px = _point_X(point); |
2673 px = _point_X(point); |
2656 py = _point_Y(point); |
2674 py = _point_Y(point); |
2657 if (! __bothSmallInteger(px, py)) |
2675 if (! __bothSmallInteger(px, py)) |
2658 goto fail; |
2676 goto fail; |
2659 } |
2677 } |
2660 |
2678 |
2661 fgColor = GetTextColor(hDC); |
2679 fgColor = GetTextColor(hDC); |
2662 hasHatch= 1; |
2680 hasHatch= 1; |
2663 |
2681 |
2664 if (hatchSymbol == @symbol(none)) { |
2682 if (hatchSymbol == @symbol(none)) { |
2665 hasHatch= 0; |
2683 hasHatch= 0; |
2666 } else if (hatchSymbol == @symbol(horizontal)) { |
2684 } else if (hatchSymbol == @symbol(horizontal)) { |
2667 hatch= HS_HORIZONTAL; |
2685 hatch= HS_HORIZONTAL; |
2668 } else if (hatchSymbol == @symbol(vertical)) { |
2686 } else if (hatchSymbol == @symbol(vertical)) { |
2669 hatch= HS_VERTICAL; |
2687 hatch= HS_VERTICAL; |
2670 } else if (hatchSymbol == @symbol(cross)) { |
2688 } else if (hatchSymbol == @symbol(cross)) { |
2671 hatch= HS_CROSS; |
2689 hatch= HS_CROSS; |
2672 } else if (hatchSymbol == @symbol(bDiagonal)) { |
2690 } else if (hatchSymbol == @symbol(bDiagonal)) { |
2673 hatch= HS_BDIAGONAL; |
2691 hatch= HS_BDIAGONAL; |
2674 } else if (hatchSymbol == @symbol(fDiagonal)) { |
2692 } else if (hatchSymbol == @symbol(fDiagonal)) { |
2675 hatch= HS_FDIAGONAL; |
2693 hatch= HS_FDIAGONAL; |
2676 } else if (hatchSymbol == @symbol(diagonalCross)) { |
2694 } else if (hatchSymbol == @symbol(diagonalCross)) { |
2677 hatch= HS_DIAGCROSS; |
2695 hatch= HS_DIAGCROSS; |
2678 } else |
2696 } else |
2679 hasHatch= 0; |
2697 hasHatch= 0; |
2680 |
2698 |
2681 if (hasHatch) { |
2699 if (hasHatch) { |
2682 hBrush = CreateHatchBrush(hatch, fgColor); |
2700 hBrush = CreateHatchBrush(hatch, fgColor); |
2683 } else { |
2701 } else { |
2684 hBrush = CreateSolidBrush(fgColor); |
2702 hBrush = CreateSolidBrush(fgColor); |
2685 } |
2703 } |
2686 |
2704 |
2687 if (hBrush == 0) { |
2705 if (hBrush == 0) { |
2688 DPRINTF(("fillPolygon: no brush\n")); |
2706 DPRINTF(("fillPolygon: no brush\n")); |
2689 } else { |
2707 } else { |
2690 HPEN prevPen; |
2708 HPEN prevPen; |
2691 |
2709 |
2692 prevBrush = SelectObject(hDC, hBrush); |
2710 prevBrush = SelectObject(hDC, hBrush); |
2693 prevPen = SelectObject(hDC, GetStockObject(NULL_PEN)); |
2711 prevPen = SelectObject(hDC, GetStockObject(NULL_PEN)); |
2694 |
2712 |
2695 BeginPath(hDC); |
2713 BeginPath(hDC); |
2696 |
2714 |
2697 for (i=0; i<num; i++) { |
2715 for (i=0; i<num; i++) { |
2698 point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
2716 point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
2699 px = _point_X(point); |
2717 px = _point_X(point); |
2700 py = _point_Y(point); |
2718 py = _point_Y(point); |
2701 if (i == 0) { |
2719 if (i == 0) { |
2702 MoveToEx(hDC, __intVal(px), __intVal(py), NULL); |
2720 MoveToEx(hDC, __intVal(px), __intVal(py), NULL); |
2703 } else { |
2721 } else { |
2704 if (i == (num-1)) { |
2722 if (i == (num-1)) { |
2705 p.x = __intVal(px); |
2723 p.x = __intVal(px); |
2706 p.y = __intVal(py); |
2724 p.y = __intVal(py); |
2707 PolylineTo(hDC, &p, 1); |
2725 PolylineTo(hDC, &p, 1); |
2708 } else { |
2726 } else { |
2709 LineTo(hDC, __intVal(px), __intVal(py)); |
2727 LineTo(hDC, __intVal(px), __intVal(py)); |
2710 } |
2728 } |
2711 } |
2729 } |
2712 } |
2730 } |
2713 |
2731 |
2714 EndPath(hDC); |
2732 EndPath(hDC); |
2715 FillPath(hDC); |
2733 FillPath(hDC); |
2716 SelectObject(hDC, prevPen); |
2734 SelectObject(hDC, prevPen); |
2717 SelectObject(hDC, prevBrush); |
2735 SelectObject(hDC, prevBrush); |
2718 DeleteObject(hBrush); |
2736 DeleteObject(hBrush); |
2719 } |
2737 } |
2720 RETURN ( self ); |
2738 RETURN ( self ); |
2721 |
2739 |
2722 fail: ; |
2740 fail: ; |
2723 } |
2741 } |
2724 %} |
2742 %} |
2725 ! |
2743 ! |
2726 |
2744 |
2727 scaleTest_displayString:aString x:x y:y |
2745 scaleTest_displayString:aString x:x y:y |
2728 "draw a string at the coordinate x/y - |
2746 "draw a string at the coordinate x/y - |
2729 draw foreground-pixels only (in current paint-color), |
2747 draw foreground-pixels only (in current paint-color), |
2730 leaving background as-is. If the transformation involves scaling, |
2748 leaving background as-is. If the transformation involves scaling, |
2731 the fonts point-size is scaled as appropriate." |
2749 the fonts point-size is scaled as appropriate." |
2732 |
2750 |
2733 |id pX pY fontUsed sz s fontsEncoding| |
2751 |id pX pY fontUsed sz s fontsEncoding| |
2734 |
2752 |
2735 "hook for non-strings (i.e. attributed text)" |
2753 "hook for non-strings (i.e. attributed text)" |
2736 (aString isString not |
2754 (aString isString not |
2737 or:[aString isText]) ifTrue:[ |
2755 or:[aString isText]) ifTrue:[ |
2738 ^ aString displayOn:self x:x y:y |
2756 ^ aString displayOn:self x:x y:y |
2739 ]. |
2757 ]. |
2740 |
2758 |
2741 gcId isNil ifTrue:[ |
2759 gcId isNil ifTrue:[ |
2742 self initGC |
2760 self initGC |
2743 ]. |
2761 ]. |
2744 |
2762 |
2745 fontUsed := font. |
2763 fontUsed := font. |
2746 transformation notNil ifTrue:[ |
2764 transformation notNil ifTrue:[ |
2747 pX := transformation applyToX:x. |
2765 pX := transformation applyToX:x. |
2748 pY := transformation applyToY:y. |
2766 pY := transformation applyToY:y. |
2749 transformation noScale ifFalse:[ |
2767 transformation noScale ifFalse:[ |
2750 sz := font size. |
2768 sz := font size. |
2751 sz isNil ifTrue:[ |
2769 sz isNil ifTrue:[ |
2752 "/ oops - not a real font; use original font |
2770 "/ oops - not a real font; use original font |
2753 fontUsed := font |
2771 fontUsed := font |
2754 ] ifFalse:[ |yS| |
2772 ] ifFalse:[ |yS| |
2755 yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch. |
2773 yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch. |
2756 yS := self scale y / yS. |
2774 yS := self scale y / yS. |
2757 fontUsed := font size:(sz * yS) rounded. |
2775 fontUsed := font size:(sz * yS) rounded. |
2758 ] |
2776 ] |
2759 ] |
2777 ] |
2760 ] ifFalse:[ |
2778 ] ifFalse:[ |
2761 pX := x. |
2779 pX := x. |
2762 pY := y. |
2780 pY := y. |
2763 ]. |
2781 ]. |
2764 pX := pX rounded. |
2782 pX := pX rounded. |
2765 pY := pY rounded. |
2783 pY := pY rounded. |
2766 |
2784 |
2767 s := aString. |
2785 s := aString. |
2768 fontUsed := fontUsed onDevice:device. |
2786 fontUsed := fontUsed onDevice:device. |
2769 fontsEncoding := fontUsed encoding. |
2787 fontsEncoding := fontUsed encoding. |
2770 (characterEncoding ~~ fontsEncoding) ifTrue:[ |
2788 (characterEncoding ~~ fontsEncoding) ifTrue:[ |
2771 [ |
2789 [ |
2772 s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding. |
2790 s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding. |
2773 ] on:CharacterEncoderError do:[:ex| |
2791 ] on:CharacterEncoderError do:[:ex| |
2774 "substitute a default value for codes that cannot be represented |
2792 "substitute a default value for codes that cannot be represented |
2775 in the new character set" |
2793 in the new character set" |
2776 ex proceedWith:ex defaultValue. |
2794 ex proceedWith:ex defaultValue. |
2777 ]. |
2795 ]. |
2778 ]. |
2796 ]. |
2779 |
2797 |
2780 id := fontUsed fontId. |
2798 id := fontUsed fontId. |
2781 id isNil ifTrue:[ |
2799 id isNil ifTrue:[ |
2782 "hook for alien fonts" |
2800 "hook for alien fonts" |
2783 fontUsed displayString:s x:x y:y in:self |
2801 fontUsed displayString:s x:x y:y in:self |
2784 ] ifFalse:[ |
2802 ] ifFalse:[ |
2785 deviceFont ~~ fontUsed ifTrue:[ |
2803 deviceFont ~~ fontUsed ifTrue:[ |
2786 device setFont:id in:gcId. |
2804 device setFont:id in:gcId. |
2787 deviceFont := fontUsed |
2805 deviceFont := fontUsed |
2788 ]. |
2806 ]. |
2789 device displayString:s x:pX y:pY in:drawableId with:gcId |
2807 device displayString:s x:pX y:pY in:drawableId with:gcId |
2790 ] |
2808 ] |
2791 |
2809 |
2792 "Modified: 1.7.1997 / 17:08:35 / cg" |
2810 "Modified: 1.7.1997 / 17:08:35 / cg" |
2793 ! ! |
2811 ! ! |
2794 |
2812 |
2831 ! |
2849 ! |
2832 |
2850 |
2833 compressColorMapImage: image |
2851 compressColorMapImage: image |
2834 "calculates a new color map for the image, using only used colors" |
2852 "calculates a new color map for the image, using only used colors" |
2835 |
2853 |
2836 |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
2854 |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
2837 |
2855 |
2838 oldImage := image. |
2856 oldImage := image. |
2839 depth := oldImage depth. |
2857 depth := oldImage depth. |
2840 |
2858 |
2841 oldImage photometric ~~ #palette ifTrue:[ |
2859 oldImage photometric ~~ #palette ifTrue:[ |
2842 Transcript showCR:'Compress colorMap: Only palette images have colormaps.'. |
2860 Transcript showCR:'Compress colorMap: Only palette images have colormaps.'. |
2843 ^ image |
2861 ^ image |
2844 ]. |
2862 ]. |
2845 |
2863 |
2846 usedColors := oldImage realUsedColors. |
2864 usedColors := oldImage realUsedColors. |
2847 usedColors size == (1 bitShift:depth) ifTrue:[ |
2865 usedColors size == (1 bitShift:depth) ifTrue:[ |
2848 Transcript showCR:'Compress colorMap: All colors are used - no compression.'. |
2866 Transcript showCR:'Compress colorMap: All colors are used - no compression.'. |
2849 ^ image |
2867 ^ image |
2850 ]. |
2868 ]. |
2851 usedColors size == oldImage colorMap size ifTrue:[ |
2869 usedColors size == oldImage colorMap size ifTrue:[ |
2852 Transcript showCR:'Compress colorMap: Colormap already compressed - no compression.'. |
2870 Transcript showCR:'Compress colorMap: Colormap already compressed - no compression.'. |
2853 ^ image |
2871 ^ image |
2854 ]. |
2872 ]. |
2855 |
2873 |
2856 "/ translation table |
2874 "/ translation table |
2857 oldToNew := ByteArray new:(1 bitShift:depth). |
2875 oldToNew := ByteArray new:(1 bitShift:depth). |
2858 newColorMap := usedColors asArray. |
2876 newColorMap := usedColors asArray. |
2859 newColorMap sort:self sortBlockForColors. |
2877 newColorMap sort:self sortBlockForColors. |
2860 |
2878 |
2861 oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
2879 oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
2862 |newPixel| |
2880 |newPixel| |
2863 |
2881 |
2864 (usedColors includes:clr) ifTrue:[ |
2882 (usedColors includes:clr) ifTrue:[ |
2865 newPixel := newColorMap indexOf:clr. |
2883 newPixel := newColorMap indexOf:clr. |
2866 oldToNew at:oldIdx put:newPixel-1. |
2884 oldToNew at:oldIdx put:newPixel-1. |
2867 ] |
2885 ] |
2868 ]. |
2886 ]. |
2869 |
2887 |
2870 oldBits := oldImage bits. |
2888 oldBits := oldImage bits. |
2871 newBits := ByteArray new:(oldBits size). |
2889 newBits := ByteArray new:(oldBits size). |
2872 depth ~~ 8 ifTrue:[ |
2890 depth ~~ 8 ifTrue:[ |
2873 "/ expand/compress can only handle 8bits |
2891 "/ expand/compress can only handle 8bits |
2874 tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
2892 tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
2875 oldBits |
2893 oldBits |
2876 expandPixels:depth |
2894 expandPixels:depth |
2877 width:oldImage width |
2895 width:oldImage width |
2878 height:oldImage height |
2896 height:oldImage height |
2879 into:tmpBits |
2897 into:tmpBits |
2880 mapping:oldToNew. |
2898 mapping:oldToNew. |
2881 tmpBits |
2899 tmpBits |
2882 compressPixels:depth |
2900 compressPixels:depth |
2883 width:oldImage width |
2901 width:oldImage width |
2884 height:oldImage height |
2902 height:oldImage height |
2885 into:newBits |
2903 into:newBits |
2886 mapping:nil |
2904 mapping:nil |
2887 ] ifFalse:[ |
2905 ] ifFalse:[ |
2888 oldBits |
2906 oldBits |
2889 expandPixels:depth |
2907 expandPixels:depth |
2890 width:oldImage width |
2908 width:oldImage width |
2891 height:oldImage height |
2909 height:oldImage height |
2892 into:newBits |
2910 into:newBits |
2893 mapping:oldToNew. |
2911 mapping:oldToNew. |
2894 ]. |
2912 ]. |
2895 |
2913 |
2896 newImage := oldImage species new |
2914 newImage := oldImage species new |
2897 width:oldImage width |
2915 width:oldImage width |
2898 height:oldImage height |
2916 height:oldImage height |
2899 depth:depth |
2917 depth:depth |
2900 fromArray:newBits. |
2918 fromArray:newBits. |
2901 |
2919 |
2902 newImage colorMap:newColorMap. |
2920 newImage colorMap:newColorMap. |
2903 newImage fileName:oldImage fileName. |
2921 newImage fileName:oldImage fileName. |
2904 newImage mask:(oldImage mask copy). |
2922 newImage mask:(oldImage mask copy). |
2905 |
2923 |
2906 ^ newImage |
2924 ^ newImage |
2907 |
2925 |
2908 "Created: / 28.7.1998 / 20:03:11 / cg" |
2926 "Created: / 28.7.1998 / 20:03:11 / cg" |
2909 "Modified: / 15.9.1998 / 17:53:32 / cg" |
2927 "Modified: / 15.9.1998 / 17:53:32 / cg" |
2910 ! |
2928 ! |
2911 |
2929 |
2912 copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId |
2930 copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId |
2913 width:w height:h |
2931 width:w height:h |
2914 "do a bit-blt; copy bits from the rectangle defined by |
2932 "do a bit-blt; copy bits from the rectangle defined by |
2915 srcX/srcY and w/h from the sourceId drawable to the rectangle |
2933 srcX/srcY and w/h from the sourceId drawable to the rectangle |
2916 below dstX/dstY in the destId drawable. Trigger an error if any |
2934 below dstX/dstY in the destId drawable. Trigger an error if any |
2917 argument is not integer." |
2935 argument is not integer." |
2918 |
2936 |
2921 HWND dstGcHWIN; |
2939 HWND dstGcHWIN; |
2922 HBITMAP dstGcHBITMAP; |
2940 HBITMAP dstGcHBITMAP; |
2923 |
2941 |
2924 if (! __isExternalAddressLike(srcGCId) |
2942 if (! __isExternalAddressLike(srcGCId) |
2925 || ! __isExternalAddressLike(dstGCId)) { |
2943 || ! __isExternalAddressLike(dstGCId)) { |
2926 goto fail; |
2944 goto fail; |
2927 } |
2945 } |
2928 |
2946 |
2929 if (__bothSmallInteger(w, h) |
2947 if (__bothSmallInteger(w, h) |
2930 && __bothSmallInteger(srcX, srcY) |
2948 && __bothSmallInteger(srcX, srcY) |
2931 && __bothSmallInteger(dstX, dstY)) { |
2949 && __bothSmallInteger(dstX, dstY)) { |
2932 HANDLE srcDC = (HANDLE)(__externalAddressVal(srcGCId)); |
2950 HANDLE srcDC = (HANDLE)(__externalAddressVal(srcGCId)); |
2933 HANDLE dstDC = (HANDLE)(__externalAddressVal(dstGCId)); |
2951 HANDLE dstDC = (HANDLE)(__externalAddressVal(dstGCId)); |
2934 |
2952 |
2935 int fun, aFunctionSymbol; |
2953 int fun; |
2936 int src_fg, src_bg, dst_fg, dst_bg; |
2954 OBJ aFunctionSymbol; |
2937 char buf[5]; |
2955 int src_fg, src_bg, dst_fg, dst_bg; |
|
2956 char buf[5]; |
2938 |
2957 |
2939 // fun = dstGcData->bitbltrop2; |
2958 // fun = dstGcData->bitbltrop2; |
2940 |
2959 |
2941 aFunctionSymbol= __INST(function); |
2960 aFunctionSymbol= __INST(function); |
2942 |
2961 |
2943 if (aFunctionSymbol == @symbol(copy)) { |
2962 if (aFunctionSymbol == @symbol(copy)) { |
2944 fun = SRCCOPY /* R2_COPYPEN */ ; |
2963 fun = SRCCOPY /* R2_COPYPEN */ ; |
2945 /* bfun = BITBLT_COPY; */ |
2964 /* bfun = BITBLT_COPY; */ |
2946 } else if (aFunctionSymbol == @symbol(copyInverted)) { |
2965 } else if (aFunctionSymbol == @symbol(copyInverted)) { |
2947 fun = NOTSRCCOPY /* R2_NOTCOPYPEN */; |
2966 fun = NOTSRCCOPY /* R2_NOTCOPYPEN */; |
2948 /* bfun = BITBLT_COPYINVERTED; */ |
2967 /* bfun = BITBLT_COPYINVERTED; */ |
2949 } else if (aFunctionSymbol == @symbol(xor)) { |
2968 } else if (aFunctionSymbol == @symbol(xor)) { |
2950 fun = SRCINVERT /* R2_XORPEN */; |
2969 fun = SRCINVERT /* R2_XORPEN */; |
2951 /* bfun = BITBLT_XOR; */ |
2970 /* bfun = BITBLT_XOR; */ |
2952 } else if (aFunctionSymbol == @symbol(and)) { |
2971 } else if (aFunctionSymbol == @symbol(and)) { |
2953 fun = SRCAND /* R2_MASKPEN */ ; |
2972 fun = SRCAND /* R2_MASKPEN */ ; |
2954 /* bfun = BITBLT_AND; */ |
2973 /* bfun = BITBLT_AND; */ |
2955 } else if (aFunctionSymbol == @symbol(or)) { |
2974 } else if (aFunctionSymbol == @symbol(or)) { |
2956 fun = MERGECOPY /* R2_MERGEPEN */ ; |
2975 fun = MERGECOPY /* R2_MERGEPEN */ ; |
2957 /* bfun = BITBLT_OR; */ |
2976 /* bfun = BITBLT_OR; */ |
2958 } |
2977 } |
2959 |
2978 |
2960 // convert 123 to string [buf] |
2979 // convert 123 to string [buf] |
2961 // itoa(fun, buf, 10); |
2980 // itoa(fun, buf, 10); |
2962 |
2981 |
2963 // console_printf(" ", buf); |
2982 // console_printf(" ", buf); |
2964 |
2983 |
2965 /* |
2984 /* |
2966 #if 0 |
2985 #if 0 |
2967 switch (fun) { |
2986 switch (fun) { |
2968 case BITBLT_COPY: |
2987 case BITBLT_COPY: |
2969 console_printf("BITBLT_COPY\n"); |
2988 console_printf("BITBLT_COPY\n"); |
2970 break; |
2989 break; |
2971 case BITBLT_COPYINVERTED: |
2990 case BITBLT_COPYINVERTED: |
2972 console_printf("BITBLT_COPYINVERTED\n"); |
2991 console_printf("BITBLT_COPYINVERTED\n"); |
2973 break; |
2992 break; |
2974 case BITBLT_XOR: |
2993 case BITBLT_XOR: |
2975 console_printf("BITBLT_XOR\n"); |
2994 console_printf("BITBLT_XOR\n"); |
2976 break; |
2995 break; |
2977 case BITBLT_AND: |
2996 case BITBLT_AND: |
2978 console_printf("BITBLT_AND\n"); |
2997 console_printf("BITBLT_AND\n"); |
2979 break; |
2998 break; |
2980 case BITBLT_OR: |
2999 case BITBLT_OR: |
2981 console_printf("BITBLT_OR\n"); |
3000 console_printf("BITBLT_OR\n"); |
2982 break; |
3001 break; |
2983 } |
3002 } |
2984 #endif |
3003 #endif |
2985 */ |
3004 */ |
2986 |
3005 |
2987 // fun = dstGcData->bitbltrop2; |
3006 // fun = dstGcData->bitbltrop2; |
2988 |
3007 |
2989 if (0 /* fun == BITBLT_COPY */) { |
3008 if (0 /* fun == BITBLT_COPY */) { |
2990 src_fg = dst_fg = 0xFFFFFF; |
3009 src_fg = dst_fg = 0xFFFFFF; |
2991 src_bg = dst_bg = 0x000000; |
3010 src_bg = dst_bg = 0x000000; |
2992 } else { |
3011 } else { |
2993 src_fg = GetTextColor(srcDC) /* srcGcData->fgColor */; |
3012 src_fg = GetTextColor(srcDC) /* srcGcData->fgColor */; |
2994 src_bg = GetBkColor(dstDC) /* srcGcData->bgColor */; |
3013 src_bg = GetBkColor(dstDC) /* srcGcData->bgColor */; |
2995 dst_fg = GetTextColor(srcDC) /* dstGcData->fgColor */; |
3014 dst_fg = GetTextColor(srcDC) /* dstGcData->fgColor */; |
2996 dst_bg = GetBkColor(dstDC) /* dstGcData->bgColor */; |
3015 dst_bg = GetBkColor(dstDC) /* dstGcData->bgColor */; |
2997 } |
3016 } |
2998 |
3017 |
2999 SetBkColor(dstDC, dst_fg); |
3018 SetBkColor(dstDC, dst_fg); |
3000 SetTextColor(dstDC, dst_bg); |
3019 SetTextColor(dstDC, dst_bg); |
3001 |
3020 |
3002 SetBkColor(srcDC, src_fg); |
3021 SetBkColor(srcDC, src_fg); |
3003 SetTextColor(srcDC, src_bg); |
3022 SetTextColor(srcDC, src_bg); |
3004 |
3023 |
3005 /* |
3024 /* |
3006 CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC))); |
3025 CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC))); |
3007 CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC))); |
3026 CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC))); |
3008 */ |
3027 */ |
3009 if (BitBlt(dstDC, |
3028 if (BitBlt(dstDC, |
3010 __intVal(dstX), __intVal(dstY), |
3029 __intVal(dstX), __intVal(dstY), |
3011 __intVal(w), __intVal(h), |
3030 __intVal(w), __intVal(h), |
3012 srcDC, |
3031 srcDC, |
3013 __intVal(srcX), __intVal(srcY), |
3032 __intVal(srcX), __intVal(srcY), |
3014 fun) |
3033 fun) |
3015 == 0 |
3034 == 0 |
3016 ) { |
3035 ) { |
3017 console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n"); |
3036 console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n"); |
3018 } |
3037 } |
3019 |
3038 |
3020 /* |
3039 /* |
3021 if (dstGcData != srcGcData) { |
3040 if (dstGcData != srcGcData) { |
3022 SetBkColor(dstDC, dstGcData->bgColor); |
3041 SetBkColor(dstDC, dstGcData->bgColor); |
3023 SetTextColor(dstDC, dstGcData->fgColor); |
3042 SetTextColor(dstDC, dstGcData->fgColor); |
3024 } |
3043 } |
3025 SetBkColor(srcDC, srcGcData->bgColor); |
3044 SetBkColor(srcDC, srcGcData->bgColor); |
3026 SetTextColor(srcDC, srcGcData->fgColor); |
3045 SetTextColor(srcDC, srcGcData->fgColor); |
3027 */ |
3046 */ |
3028 |
3047 |
3029 /* |
3048 /* |
3030 if (srcGcData != dstGcData) { |
3049 if (srcGcData != dstGcData) { |
3031 _releaseDC(srcGcData); |
3050 _releaseDC(srcGcData); |
3032 } |
3051 } |
3033 _releaseDC(dstGcData); |
3052 _releaseDC(dstGcData); |
3034 */ |
3053 */ |
3035 RETURN ( self ); |
3054 RETURN ( self ); |
3036 } |
3055 } |
3037 |
3056 |
3038 fail: ; |
3057 fail: ; |
3039 %}. |
3058 %}. |
3040 self primitiveFailed. |
3059 self primitiveFailed. |
3137 |
3156 |
3138 sortedImage := aForm. |
3157 sortedImage := aForm. |
3139 |
3158 |
3140 "Image 16 bits" |
3159 "Image 16 bits" |
3141 aForm depth = 16 ifTrue:[ |
3160 aForm depth = 16 ifTrue:[ |
3142 bitsWithTransparency := aForm bits. |
3161 bitsWithTransparency := aForm bits. |
3143 ]. |
3162 ]. |
3144 "Image 24 and 32 bits" |
3163 "Image 24 and 32 bits" |
3145 aForm depth >= 24 ifTrue:[ |
3164 aForm depth >= 24 ifTrue:[ |
3146 |bestFormat| |
3165 |bestFormat| |
3147 bestFormat := aForm bestSupportedImageFormatFor: Display. |
3166 bestFormat := aForm bestSupportedImageFormatFor: Display. |
3148 bitsWithTransparency := aForm rgbImageBitsOn: Display bestFormat: bestFormat. |
3167 bitsWithTransparency := aForm rgbImageBitsOn: Display bestFormat: bestFormat. |
3149 ]. |
3168 ]. |
3150 "Image up to 8 bits" |
3169 "Image up to 8 bits" |
3151 aForm depth <= 8 ifTrue:[ |
3170 aForm depth <= 8 ifTrue:[ |
3152 aForm depth < 8 ifTrue:[ |
3171 aForm depth < 8 ifTrue:[ |
3153 sortedImage := aForm asImageWithDepth: 8. |
3172 sortedImage := aForm asImageWithDepth: 8. |
3154 ]. |
3173 ]. |
3155 "/ sortedImage := self sortColorMapImage: aForm. |
3174 "/ sortedImage := self sortColorMapImage: aForm. |
3156 sortedImage := self compressColorMapImage: sortedImage. |
3175 sortedImage := self compressColorMapImage: sortedImage. |
3157 |
3176 |
3158 formMask := sortedImage mask. |
3177 formMask := sortedImage mask. |
3159 formMask isNil |
3178 formMask isNil |
3160 ifTrue:[bitsWithTransparency := sortedImage bits ] |
3179 ifTrue:[bitsWithTransparency := sortedImage bits ] |
3161 ifFalse:[ |
3180 ifFalse:[ |
3162 |bitsWithTransparencySize| |
3181 |bitsWithTransparencySize| |
3163 formMask := formMask asImageWithDepth: sortedImage depth. |
3182 formMask := formMask asImageWithDepth: sortedImage depth. |
3164 bitsWithTransparency := sortedImage bits copy. |
3183 bitsWithTransparency := sortedImage bits copy. |
3165 bitsWithTransparencySize := bitsWithTransparency size. |
3184 bitsWithTransparencySize := bitsWithTransparency size. |
3166 formMask bits doWithIndex:[:maskBit :index | |
3185 formMask bits doWithIndex:[:maskBit :index | |
3167 bitsWithTransparencySize >= index ifTrue:[ |
3186 bitsWithTransparencySize >= index ifTrue:[ |
3168 maskBit == 0 ifTrue:[bitsWithTransparency at: index put: 255 "60" "bitClearAt: index"]. |
3187 maskBit == 0 ifTrue:[bitsWithTransparency at: index put: 255 "60" "bitClearAt: index"]. |
3169 "/ maskBit == 1 ifTrue:[bitsWithTransparency at: index put: (bitsWithTransparency at: index)]. |
3188 "/ maskBit == 1 ifTrue:[bitsWithTransparency at: index put: (bitsWithTransparency at: index)]. |
3170 ]. |
3189 ]. |
3171 ]. |
3190 ]. |
3172 ]. |
3191 ]. |
3173 |
3192 |
3174 redVector := sortedImage colorMap redVector. |
3193 redVector := sortedImage colorMap redVector. |
3175 greenVector := sortedImage colorMap greenVector. |
3194 greenVector := sortedImage colorMap greenVector. |
3176 blueVector := sortedImage colorMap blueVector. |
3195 blueVector := sortedImage colorMap blueVector. |
3177 ]. |
3196 ]. |
3178 |
3197 |
3179 self |
3198 self |
3180 drawBits: bitsWithTransparency |
3199 drawBits: bitsWithTransparency |
3181 redVector: redVector |
3200 redVector: redVector |
3182 greenVector: greenVector |
3201 greenVector: greenVector |
3183 blueVector: blueVector |
3202 blueVector: blueVector |
3184 bitsPerPixel: sortedImage bitsPerPixel |
3203 bitsPerPixel: sortedImage bitsPerPixel |
3185 depth: sortedImage depth |
3204 depth: sortedImage depth |
3186 width: sortedImage width |
3205 width: sortedImage width |
3187 height: sortedImage height |
3206 height: sortedImage height |
3188 into: self id |
3207 into: self id |
3189 x: x |
3208 x: x |
3190 y: y |
3209 y: y |
3191 width: sortedImage width |
3210 width: sortedImage width |
3192 height: sortedImage height |
3211 height: sortedImage height |
3193 with: gcId. |
3212 with: gcId. |
3194 ! |
3213 ! |
3195 |
3214 |
3196 drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd |
3215 drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd |
3197 width:imageWidth height:imageHeight |
3216 width:imageWidth height:imageHeight |
3198 x:srcx y:srcy |
3217 x:srcx y:srcy |
3199 into:ignoredDrawableId |
3218 into:ignoredDrawableId |
3200 x:dstx y:dsty |
3219 x:dstx y:dsty |
3201 width:w height:h |
3220 width:w height:h |
3202 with:aGCId |
3221 with:aGCId |
3203 |
3222 |
3204 "draw a bitImage which has depth id, width iw and height ih into |
3223 "draw a bitImage which has depth id, width iw and height ih into |
3205 the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
3224 the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
3206 Individual source pixels have bitsPerPixel bits, allowing to draw |
3225 Individual source pixels have bitsPerPixel bits, allowing to draw |
3207 depth and pixel-units to be different. |
3226 depth and pixel-units to be different. |
3274 unsigned char *allocatedBits = 0; |
3293 unsigned char *allocatedBits = 0; |
3275 unsigned char fastBits[10000]; |
3294 unsigned char fastBits[10000]; |
3276 |
3295 |
3277 if (__bothSmallInteger(w, h) |
3296 if (__bothSmallInteger(w, h) |
3278 && __isNonNilObject(anArray)) { |
3297 && __isNonNilObject(anArray)) { |
3279 OBJ cls = __qClass(anArray); |
3298 OBJ cls = __qClass(anArray); |
3280 |
3299 |
3281 b_width = __intVal(w); |
3300 b_width = __intVal(w); |
3282 b_height = __intVal(h); |
3301 b_height = __intVal(h); |
3283 bytesPerRowST = (b_width + 7) / 8; |
3302 bytesPerRowST = (b_width + 7) / 8; |
3284 bytesPerRowWN = ((b_width + 15) / 16) * 2; |
3303 bytesPerRowWN = ((b_width + 15) / 16) * 2; |
3285 padding = bytesPerRowWN - bytesPerRowST; |
3304 padding = bytesPerRowWN - bytesPerRowST; |
3286 |
3305 |
3287 if ((padding == 0) && (cls == @global(ByteArray))) { |
3306 if ((padding == 0) && (cls == @global(ByteArray))) { |
3288 b_bits = __ByteArrayInstPtr(anArray)->ba_element; |
3307 b_bits = __ByteArrayInstPtr(anArray)->ba_element; |
3289 cp = 0; |
3308 cp = 0; |
3290 } else { |
3309 } else { |
3291 int nBytes = b_height * bytesPerRowWN; |
3310 int nBytes = b_height * bytesPerRowWN; |
3292 |
3311 |
3293 if (nBytes < sizeof(fastBits)) { |
3312 if (nBytes < sizeof(fastBits)) { |
3294 cp = b_bits = fastBits; |
3313 cp = b_bits = fastBits; |
3295 } else { |
3314 } else { |
3296 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3315 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3297 if (! cp) goto fail; |
3316 if (! cp) goto fail; |
3298 } |
3317 } |
3299 } |
3318 } |
3300 if (cp) { |
3319 if (cp) { |
3301 if (__qIsArrayLike(anArray)) { |
3320 if (__qIsArrayLike(anArray)) { |
3302 OBJ *op; |
3321 OBJ *op; |
3303 |
3322 |
3304 index = 1; |
3323 index = 1; |
3305 op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
3324 op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
3306 for (row = b_height; row; row--) { |
3325 for (row = b_height; row; row--) { |
3307 for (col = bytesPerRowST; col; col--) { |
3326 for (col = bytesPerRowST; col; col--) { |
3308 num = *op++; |
3327 num = *op++; |
3309 if (! __isSmallInteger(num)) |
3328 if (! __isSmallInteger(num)) |
3310 goto fail; |
3329 goto fail; |
3311 *cp++ = __intVal(num); |
3330 *cp++ = __intVal(num); |
3312 } |
3331 } |
3313 cp += padding; |
3332 cp += padding; |
3314 } |
3333 } |
3315 } else if (__qIsByteArrayLike(anArray)) { |
3334 } else if (__qIsByteArrayLike(anArray)) { |
3316 unsigned char *pBits; |
3335 unsigned char *pBits; |
3317 |
3336 |
3318 pBits = __ByteArrayInstPtr(anArray)->ba_element; |
3337 pBits = __ByteArrayInstPtr(anArray)->ba_element; |
3319 for (row = b_height; row; row--) { |
3338 for (row = b_height; row; row--) { |
3320 for (col = bytesPerRowST; col; col--) { |
3339 for (col = bytesPerRowST; col; col--) { |
3321 *cp++ = ( *pBits++ /*^ 0xFF*/ ); |
3340 *cp++ = ( *pBits++ /*^ 0xFF*/ ); |
3322 } |
3341 } |
3323 cp += padding; |
3342 cp += padding; |
3324 } |
3343 } |
3325 } else { |
3344 } else { |
3326 goto fail; |
3345 goto fail; |
3327 } |
3346 } |
3328 } |
3347 } |
3329 /* |
3348 /* |
3330 CPRINTF(("create bitmap ...\n")); |
3349 CPRINTF(("create bitmap ...\n")); |
3331 */ |
3350 */ |
3332 newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits ); |
3351 newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits ); |
3333 |
3352 |
3334 if (newBitmapHandle ) { |
3353 if (newBitmapHandle ) { |
3335 /* |
3354 /* |
3336 DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle)); |
3355 DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle)); |
3337 */ |
3356 */ |
3338 if (allocatedBits) { |
3357 if (allocatedBits) { |
3339 free(allocatedBits); |
3358 free(allocatedBits); |
3340 } |
3359 } |
3341 RETURN ( __MKEXTERNALADDRESS(newBitmapHandle)); |
3360 RETURN ( __MKEXTERNALADDRESS(newBitmapHandle)); |
3342 } |
3361 } |
3343 } |
3362 } |
3344 fail: ; |
3363 fail: ; |
3345 /* |
3364 /* |
3346 DDPRINTF(("create bitmap FAILED!!!\n")); |
3365 DDPRINTF(("create bitmap FAILED!!!\n")); |
3347 */ |
3366 */ |
3348 if (allocatedBits) { |
3367 if (allocatedBits) { |
3349 /* |
3368 /* |
3350 CPRINTF(("freeing up bitmap bits ...\n")); |
3369 CPRINTF(("freeing up bitmap bits ...\n")); |
3351 */ |
3370 */ |
3352 free(allocatedBits); |
3371 free(allocatedBits); |
3353 } |
3372 } |
3354 /* |
3373 /* |
3355 CPRINTF(("returning nil ...\n")); |
3374 CPRINTF(("returning nil ...\n")); |
3356 */ |
3375 */ |
3357 RETURN ( nil ); |
3376 RETURN ( nil ); |
3358 %} |
3377 %} |
3359 ! |
3378 ! |
3360 |
3379 |
3361 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd |
3380 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd |
3362 width:imageWidth height:imageHeight |
3381 width:imageWidth height:imageHeight |
3363 x:srcx y:srcy |
3382 x:srcx y:srcy |
3364 into:ignoredDrawableId |
3383 into:ignoredDrawableId |
3365 x:dstx y:dsty |
3384 x:dstx y:dsty |
3366 width:w height:h |
3385 width:w height:h |
3367 with:aGCId |
3386 with:aGCId |
3368 |
3387 |
3369 "since XPutImage may allocate huge amount of stack space |
3388 "since XPutImage may allocate huge amount of stack space |
3370 (some implementations use alloca), this must run with unlimited stack." |
3389 (some implementations use alloca), this must run with unlimited stack." |
3371 |
3390 |
3372 %{ |
3391 %{ |
3389 && __bothSmallInteger(imageWidth, imageHeight) |
3408 && __bothSmallInteger(imageWidth, imageHeight) |
3390 && __bothSmallInteger(imageDepth, bitsPerPixel) |
3409 && __bothSmallInteger(imageDepth, bitsPerPixel) |
3391 && __isSmallInteger(padd) |
3410 && __isSmallInteger(padd) |
3392 && __imageBits) |
3411 && __imageBits) |
3393 { |
3412 { |
3394 struct |
3413 struct |
3395 { |
3414 { |
3396 BITMAPINFOHEADER bmiHeader; |
3415 BITMAPINFOHEADER bmiHeader; |
3397 DWORD r; |
3416 DWORD r; |
3398 DWORD g; |
3417 DWORD g; |
3399 DWORD b; |
3418 DWORD b; |
3400 } bitmap; |
3419 } bitmap; |
3401 |
3420 |
3402 HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
3421 HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
3403 HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
3422 HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
3404 |
3423 |
3405 /* |
3424 /* |
3406 DDPRINTF(("hDC = %x\n", hDC)); |
3425 DDPRINTF(("hDC = %x\n", hDC)); |
3407 */ |
3426 */ |
3408 if (__intVal(padd) != WIN32PADDING) { |
3427 if (__intVal(padd) != WIN32PADDING) { |
3409 int row, col; |
3428 int row, col; |
3410 unsigned char *cp; |
3429 unsigned char *cp; |
3411 unsigned char *pBits; |
3430 unsigned char *pBits; |
3412 int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
3431 int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
3413 int bi = __intVal(bitsPerPixel); |
3432 int bi = __intVal(bitsPerPixel); |
3414 |
3433 |
3415 b_width = __intVal(w); |
3434 b_width = __intVal(w); |
3416 b_height = __intVal(h); |
3435 b_height = __intVal(h); |
3417 bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd); |
3436 bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd); |
3418 bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
3437 bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
3419 padding = bytesPerRowWN - bytesPerRowST; |
3438 padding = bytesPerRowWN - bytesPerRowST; |
3420 nBytes = b_height * bytesPerRowWN; |
3439 nBytes = b_height * bytesPerRowWN; |
3421 /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
3440 /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
3422 if (padding) { |
3441 if (padding) { |
3423 if (nBytes < sizeof(fastBits)) { |
3442 if (nBytes < sizeof(fastBits)) { |
3424 cp = b_bits = fastBits; |
3443 cp = b_bits = fastBits; |
3425 } else { |
3444 } else { |
3426 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3445 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3427 } |
3446 } |
3428 if (cp) { |
3447 if (cp) { |
3429 pBits = __imageBits; |
3448 pBits = __imageBits; |
3430 for (row = b_height; row; row--) { |
3449 for (row = b_height; row; row--) { |
3431 for (col = bytesPerRowST; col; col--) { |
3450 for (col = bytesPerRowST; col; col--) { |
3432 *cp++ = *pBits++; |
3451 *cp++ = *pBits++; |
3433 } |
3452 } |
3434 cp += padding; |
3453 cp += padding; |
3435 } |
3454 } |
3436 } else |
3455 } else |
3437 goto fail; |
3456 goto fail; |
3438 } |
3457 } |
3439 } |
3458 } |
3440 |
3459 |
3441 if (b_bits == 0) { |
3460 if (b_bits == 0) { |
3442 b_bits = __imageBits; |
3461 b_bits = __imageBits; |
3443 } |
3462 } |
3444 |
3463 |
3445 bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
3464 bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
3446 bitmap.bmiHeader.biPlanes = 1; |
3465 bitmap.bmiHeader.biPlanes = 1; |
3447 if (__intVal(imageDepth) == 24) { |
3466 if (__intVal(imageDepth) == 24) { |
3448 /*bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
3467 /*bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
3449 bitmap.r = 0xff0000; |
3468 bitmap.r = 0xff0000; |
3450 bitmap.g = 0x00ff00; |
3469 bitmap.g = 0x00ff00; |
3451 bitmap.b = 0x0000ff;*/ |
3470 bitmap.b = 0x0000ff;*/ |
3452 bitmap.bmiHeader.biCompression = BI_RGB; |
3471 bitmap.bmiHeader.biCompression = BI_RGB; |
3453 } else if (__intVal(imageDepth) == 16) { |
3472 } else if (__intVal(imageDepth) == 16) { |
3454 /*bitmap.bmiHeader.biCompression = BI_RGB; |
3473 /*bitmap.bmiHeader.biCompression = BI_RGB; |
3455 bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
3474 bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
3456 bitmap.b = 0x001f; |
3475 bitmap.b = 0x001f; |
3457 bitmap.g = 0x07e0; |
3476 bitmap.g = 0x07e0; |
3458 bitmap.r = 0xf800;*/ |
3477 bitmap.r = 0xf800;*/ |
3459 bitmap.b = 0; |
3478 bitmap.b = 0; |
3460 bitmap.g = 0; |
3479 bitmap.g = 0; |
3461 bitmap.r = 0; |
3480 bitmap.r = 0; |
3462 bitmap.bmiHeader.biCompression = BI_RGB; |
3481 bitmap.bmiHeader.biCompression = BI_RGB; |
3463 } |
3482 } |
3464 bitmap.bmiHeader.biSizeImage = 0; |
3483 bitmap.bmiHeader.biSizeImage = 0; |
3465 bitmap.bmiHeader.biXPelsPerMeter = 0; |
3484 bitmap.bmiHeader.biXPelsPerMeter = 0; |
3466 bitmap.bmiHeader.biYPelsPerMeter = 0; |
3485 bitmap.bmiHeader.biYPelsPerMeter = 0; |
3467 bitmap.bmiHeader.biClrUsed = 0; |
3486 bitmap.bmiHeader.biClrUsed = 0; |
3468 bitmap.bmiHeader.biClrImportant = 0; |
3487 bitmap.bmiHeader.biClrImportant = 0; |
3469 bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
3488 bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
3470 bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
3489 bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
3471 bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
3490 bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
3472 /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
3491 /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
3473 |
3492 |
3474 SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
3493 SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
3475 __intVal(w), __intVal(h), |
3494 __intVal(w), __intVal(h), |
3476 __intVal(srcx), __intVal(srcy), |
3495 __intVal(srcx), __intVal(srcy), |
3477 0,__intVal(h), |
3496 0,__intVal(h), |
3478 (void *)b_bits, |
3497 (void *)b_bits, |
3479 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3498 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3480 |
3499 |
3481 /* |
3500 /* |
3482 SetDIBits(hDC,hBitmap, |
3501 SetDIBits(hDC,hBitmap, |
3483 0,__intVal(h), |
3502 0,__intVal(h), |
3484 (void *)b_bits, |
3503 (void *)b_bits, |
3485 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3504 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3486 */ |
3505 */ |
3487 /* |
3506 /* |
3488 StretchDIBits(hDC, |
3507 StretchDIBits(hDC, |
3489 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
3508 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
3490 __intVal(w), __intVal(h), // width & height of destination rectangle |
3509 __intVal(w), __intVal(h), // width & height of destination rectangle |
3491 __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
3510 __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
3492 __intVal(w), __intVal(h), // width & height of source rectangle |
3511 __intVal(w), __intVal(h), // width & height of source rectangle |
3493 (void *)b_bits, // bitmap bits |
3512 (void *)b_bits, // bitmap bits |
3494 (BITMAPINFO*)&bitmap, // bitmap data |
3513 (BITMAPINFO*)&bitmap, // bitmap data |
3495 DIB_RGB_COLORS, // usage options |
3514 DIB_RGB_COLORS, // usage options |
3496 SRCCOPY // raster operation code |
3515 SRCCOPY // raster operation code |
3497 ); |
3516 ); |
3498 */ |
3517 */ |
3499 if (allocatedBits) { |
3518 if (allocatedBits) { |
3500 free(allocatedBits); |
3519 free(allocatedBits); |
3501 } |
3520 } |
3502 /* |
3521 /* |
3503 #ifndef CACHE_LAST_DC |
3522 #ifndef CACHE_LAST_DC |
3504 _releaseDC(gcData); |
3523 _releaseDC(gcData); |
3505 #endif |
3524 #endif |
3506 */ |
3525 */ |
3507 RETURN ( true ); |
3526 RETURN ( true ); |
3508 } |
3527 } |
3509 |
3528 |
3510 fail: ; |
3529 fail: ; |
3511 /* |
3530 /* |
3512 PRINTF(("create temp bitmap FAILED!!!\n")); |
3531 PRINTF(("create temp bitmap FAILED!!!\n")); |
3513 */ |
3532 */ |
3514 if (allocatedBits) { |
3533 if (allocatedBits) { |
3515 /* |
3534 /* |
3516 PRINTF(("freeing up temp bitmap bits ...\n")); |
3535 PRINTF(("freeing up temp bitmap bits ...\n")); |
3517 */ |
3536 */ |
3518 free(allocatedBits); |
3537 free(allocatedBits); |
3519 } |
3538 } |
3520 /* |
3539 /* |
3521 #ifndef CACHE_LAST_DC |
3540 #ifndef CACHE_LAST_DC |
3522 if (hDC) { |
3541 if (hDC) { |
3523 _releaseDC(gcData); |
3542 _releaseDC(gcData); |
3524 } |
3543 } |
3525 #endif |
3544 #endif |
3526 */ |
3545 */ |
3527 %} |
3546 %} |
3528 . |
3547 . |
3529 ^ false |
3548 ^ false |
3530 ! |
3549 ! |
3531 |
3550 |
3532 primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
3551 primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
3533 width:imageWidth height:imageHeight |
3552 width:imageWidth height:imageHeight |
3534 into:ignoredDrawableId |
3553 into:ignoredDrawableId |
3535 x:dstx y:dsty |
3554 x:dstx y:dsty |
3536 width:w height:h |
3555 width:w height:h |
3537 with:aGCId |
3556 with:aGCId |
3538 |
3557 |
3539 "since XPutImage may allocate huge amount of stack space |
3558 "since XPutImage may allocate huge amount of stack space |
3540 (some implementations use alloca), this must run with unlimited stack." |
3559 (some implementations use alloca), this must run with unlimited stack." |
3541 |
3560 |
3542 %{ |
3561 %{ |
3580 && __bothSmallInteger(w, h) |
3599 && __bothSmallInteger(w, h) |
3581 && __bothSmallInteger(imageWidth, imageHeight) |
3600 && __bothSmallInteger(imageWidth, imageHeight) |
3582 && __bothSmallInteger(imageDepth, bitsPerPixel) |
3601 && __bothSmallInteger(imageDepth, bitsPerPixel) |
3583 && __imageBits) |
3602 && __imageBits) |
3584 { |
3603 { |
3585 struct |
3604 struct |
3586 { |
3605 { |
3587 BITMAPINFOHEADER bmiHeader; |
3606 BITMAPINFOHEADER bmiHeader; |
3588 RGBQUAD bmiColors[256]; |
3607 RGBQUAD bmiColors[256]; |
3589 } bitmap; |
3608 } bitmap; |
3590 |
3609 |
3591 HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
3610 HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
3592 HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
3611 HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
3593 int col; |
3612 int col; |
3594 /* |
3613 /* |
3595 DDPRINTF(("hDC = %x\n", hDC)); |
3614 DDPRINTF(("hDC = %x\n", hDC)); |
3596 */ |
3615 */ |
3597 |
3616 |
3598 if (padd != WIN32PADDING) { |
3617 if (padd != WIN32PADDING) { |
3599 |
3618 |
3600 int row, col; |
3619 int row, col; |
3601 unsigned char *cp; |
3620 unsigned char *cp; |
3602 unsigned char *pBits; |
3621 unsigned char *pBits; |
3603 int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
3622 int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
3604 int bi = __intVal(bitsPerPixel); |
3623 int bi = __intVal(bitsPerPixel); |
3605 |
3624 |
3606 // console_fprintf(stderr, "Non WIN32PADDING"); |
3625 // console_fprintf(stderr, "Non WIN32PADDING"); |
3607 |
3626 |
3608 b_width = __intVal(w); |
3627 b_width = __intVal(w); |
3609 b_height = __intVal(h); |
3628 b_height = __intVal(h); |
3610 bytesPerRowST = (b_width * bi + (padd - 1 )) / padd; |
3629 bytesPerRowST = (b_width * bi + (padd - 1 )) / padd; |
3611 bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
3630 bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
3612 padding = bytesPerRowWN - bytesPerRowST; |
3631 padding = bytesPerRowWN - bytesPerRowST; |
3613 nBytes = b_height * bytesPerRowWN; |
3632 nBytes = b_height * bytesPerRowWN; |
3614 /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
3633 /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
3615 if (padding) { |
3634 if (padding) { |
3616 if (nBytes < sizeof(fastBits)) { |
3635 if (nBytes < sizeof(fastBits)) { |
3617 cp = b_bits = fastBits; |
3636 cp = b_bits = fastBits; |
3618 } else { |
3637 } else { |
3619 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3638 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3620 } |
3639 } |
3621 if (cp) { |
3640 if (cp) { |
3622 pBits = __imageBits; |
3641 pBits = __imageBits; |
3623 for (row = b_height; row; row--) { |
3642 for (row = b_height; row; row--) { |
3624 for (col = bytesPerRowST; col; col--) { |
3643 for (col = bytesPerRowST; col; col--) { |
3625 *cp++ = *pBits++; |
3644 *cp++ = *pBits++; |
3626 } |
3645 } |
3627 cp += padding; |
3646 cp += padding; |
3628 } |
3647 } |
3629 } else |
3648 } else |
3630 goto fail; |
3649 goto fail; |
3631 } |
3650 } |
3632 } |
3651 } |
3633 |
3652 |
3634 if (b_bits == 0) { |
3653 if (b_bits == 0) { |
3635 b_bits = __imageBits; |
3654 b_bits = __imageBits; |
3636 } |
3655 } |
3637 |
3656 |
3638 bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
3657 bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
3639 bitmap.bmiHeader.biPlanes = 1; |
3658 bitmap.bmiHeader.biPlanes = 1; |
3640 bitmap.bmiHeader.biCompression = BI_RGB; |
3659 bitmap.bmiHeader.biCompression = BI_RGB; |
3641 bitmap.bmiHeader.biSizeImage = 0; |
3660 bitmap.bmiHeader.biSizeImage = 0; |
3642 bitmap.bmiHeader.biXPelsPerMeter = 0; |
3661 bitmap.bmiHeader.biXPelsPerMeter = 0; |
3643 bitmap.bmiHeader.biYPelsPerMeter = 0; |
3662 bitmap.bmiHeader.biYPelsPerMeter = 0; |
3644 bitmap.bmiHeader.biClrUsed = 0; |
3663 bitmap.bmiHeader.biClrUsed = 0; |
3645 bitmap.bmiHeader.biClrImportant = 0; |
3664 bitmap.bmiHeader.biClrImportant = 0; |
3646 bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
3665 bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
3647 bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
3666 bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
3648 bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
3667 bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
3649 /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
3668 /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
3650 |
3669 |
3651 if (__intVal(imageDepth) <= 8) { |
3670 if (__intVal(imageDepth) <= 8) { |
3652 for(col=0;col<256;col++) |
3671 for(col=0;col<256;col++) |
3653 { |
3672 { |
3654 bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed |
3673 bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed |
3655 bitmap.bmiColors[col].rgbGreen = __greenVector[col]; |
3674 bitmap.bmiColors[col].rgbGreen = __greenVector[col]; |
3656 bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue |
3675 bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue |
3657 bitmap.bmiColors[col].rgbReserved = 0; |
3676 bitmap.bmiColors[col].rgbReserved = 0; |
3658 |
3677 |
3659 } |
3678 } |
3660 } |
3679 } |
3661 |
3680 |
3662 bitmap.bmiColors[255].rgbBlue=255; |
3681 bitmap.bmiColors[255].rgbBlue=255; |
3663 bitmap.bmiColors[255].rgbGreen=255; |
3682 bitmap.bmiColors[255].rgbGreen=255; |
3664 bitmap.bmiColors[255].rgbRed =255; |
3683 bitmap.bmiColors[255].rgbRed =255; |
3665 |
3684 |
3666 SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
3685 SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
3667 __intVal(w), __intVal(h), |
3686 __intVal(w), __intVal(h), |
3668 0, 0, /* __intVal(srcx), __intVal(srcy), */ |
3687 0, 0, /* __intVal(srcx), __intVal(srcy), */ |
3669 0,__intVal(h), |
3688 0,__intVal(h), |
3670 (void *)b_bits, |
3689 (void *)b_bits, |
3671 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3690 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3672 /* |
3691 /* |
3673 SetDIBits(hDC,hBitmap, |
3692 SetDIBits(hDC,hBitmap, |
3674 0,__intVal(h), |
3693 0,__intVal(h), |
3675 (void *)b_bits, |
3694 (void *)b_bits, |
3676 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3695 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
3677 */ |
3696 */ |
3678 /* |
3697 /* |
3679 StretchDIBits(hDC, |
3698 StretchDIBits(hDC, |
3680 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
3699 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
3681 __intVal(w), __intVal(h), // width & height of destination rectangle |
3700 __intVal(w), __intVal(h), // width & height of destination rectangle |
3682 __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
3701 __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
3683 __intVal(w), __intVal(h), // width & height of source rectangle |
3702 __intVal(w), __intVal(h), // width & height of source rectangle |
3684 (void *)b_bits, // bitmap bits |
3703 (void *)b_bits, // bitmap bits |
3685 (BITMAPINFO*)&bitmap, // bitmap data |
3704 (BITMAPINFO*)&bitmap, // bitmap data |
3686 DIB_RGB_COLORS, // usage options |
3705 DIB_RGB_COLORS, // usage options |
3687 SRCCOPY // raster operation code |
3706 SRCCOPY // raster operation code |
3688 ); |
3707 ); |
3689 */ |
3708 */ |
3690 if (allocatedBits) { |
3709 if (allocatedBits) { |
3691 free(allocatedBits); |
3710 free(allocatedBits); |
3692 } |
3711 } |
3693 /* |
3712 /* |
3694 #ifndef CACHE_LAST_DC |
3713 #ifndef CACHE_LAST_DC |
3695 _releaseDC(gcData); |
3714 _releaseDC(gcData); |
3696 #endif |
3715 #endif |
3697 */ |
3716 */ |
3698 RETURN ( true ); |
3717 RETURN ( true ); |
3699 } |
3718 } |
3700 |
3719 |
3701 fail: ; |
3720 fail: ; |
3702 /* |
3721 /* |
3703 PRINTF(("create temp bitmap FAILED!!!\n")); |
3722 PRINTF(("create temp bitmap FAILED!!!\n")); |
3704 */ |
3723 */ |
3705 if (allocatedBits) { |
3724 if (allocatedBits) { |
3706 /* |
3725 /* |
3707 PRINTF(("freeing up temp bitmap bits ...\n")); |
3726 PRINTF(("freeing up temp bitmap bits ...\n")); |
3708 */ |
3727 */ |
3709 free(allocatedBits); |
3728 free(allocatedBits); |
3710 } |
3729 } |
3711 /* |
3730 /* |
3712 #ifndef CACHE_LAST_DC |
3731 #ifndef CACHE_LAST_DC |
3713 if (hDC) { |
3732 if (hDC) { |
3714 _releaseDC(gcData); |
3733 _releaseDC(gcData); |
3715 } |
3734 } |
3716 #endif |
3735 #endif |
3717 */ |
3736 */ |
3718 %} |
3737 %} |
3719 . |
3738 . |
3794 ! |
3813 ! |
3795 |
3814 |
3796 sortBlockForColors |
3815 sortBlockForColors |
3797 |
3816 |
3798 ^ [:a :b | |
3817 ^ [:a :b | |
3799 a redByte == b redByte ifTrue:[ |
3818 a redByte == b redByte ifTrue:[ |
3800 a greenByte == b greenByte ifTrue:[ |
3819 a greenByte == b greenByte ifTrue:[ |
3801 a blueByte < b blueByte |
3820 a blueByte < b blueByte |
3802 ] ifFalse:[ |
3821 ] ifFalse:[ |
3803 a greenByte < b greenByte |
3822 a greenByte < b greenByte |
3804 ] |
3823 ] |
3805 ] ifFalse:[ |
3824 ] ifFalse:[ |
3806 a redByte < b redByte |
3825 a redByte < b redByte |
3807 ] |
3826 ] |
3808 ]. |
3827 ]. |
3809 ! |
3828 ! |
3810 |
3829 |
3811 sortColorMapImage: image |
3830 sortColorMapImage: image |
3812 "calculates a new color map for the image, sorting colors" |
3831 "calculates a new color map for the image, sorting colors" |
3813 |
3832 |
3814 |sortBlock depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
3833 |sortBlock depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
3815 |
3834 |
3816 sortBlock := self sortBlockForColors. |
3835 sortBlock := self sortBlockForColors. |
3817 oldImage := image. |
3836 oldImage := image. |
3818 depth := oldImage depth. |
3837 depth := oldImage depth. |
3819 |
3838 |
3820 oldImage photometric ~~ #palette ifTrue:[ |
3839 oldImage photometric ~~ #palette ifTrue:[ |
3821 Transcript showCR:'Compress colorMap: Only palette images have colormaps.'. |
3840 Transcript showCR:'Compress colorMap: Only palette images have colormaps.'. |
3822 ^ image |
3841 ^ image |
3823 ]. |
3842 ]. |
3824 |
3843 |
3825 usedColors := oldImage realColorMap. |
3844 usedColors := oldImage realColorMap. |
3826 |
3845 |
3827 |
3846 |
3828 "/ translation table |
3847 "/ translation table |
3829 oldToNew := ByteArray new:(1 bitShift:depth). |
3848 oldToNew := ByteArray new:(1 bitShift:depth). |
3830 newColorMap := usedColors asArray. |
3849 newColorMap := usedColors asArray. |
3831 newColorMap sort:sortBlock. |
3850 newColorMap sort:sortBlock. |
3832 |
3851 |
3833 oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
3852 oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
3834 |newPixel| |
3853 |newPixel| |
3835 |
3854 |
3836 (usedColors includes:clr) ifTrue:[ |
3855 (usedColors includes:clr) ifTrue:[ |
3837 newPixel := newColorMap indexOf:clr. |
3856 newPixel := newColorMap indexOf:clr. |
3838 oldToNew at:oldIdx put:newPixel-1. |
3857 oldToNew at:oldIdx put:newPixel-1. |
3839 ] |
3858 ] |
3840 ]. |
3859 ]. |
3841 |
3860 |
3842 oldBits := oldImage bits. |
3861 oldBits := oldImage bits. |
3843 newBits := ByteArray new:(oldBits size). |
3862 newBits := ByteArray new:(oldBits size). |
3844 depth ~~ 8 ifTrue:[ |
3863 depth ~~ 8 ifTrue:[ |
3845 "/ expand/compress can only handle 8bits |
3864 "/ expand/compress can only handle 8bits |
3846 tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
3865 tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
3847 oldBits |
3866 oldBits |
3848 expandPixels:depth |
3867 expandPixels:depth |
3849 width:oldImage width |
3868 width:oldImage width |
3850 height:oldImage height |
3869 height:oldImage height |
3851 into:tmpBits |
3870 into:tmpBits |
3852 mapping:oldToNew. |
3871 mapping:oldToNew. |
3853 tmpBits |
3872 tmpBits |
3854 compressPixels:depth |
3873 compressPixels:depth |
3855 width:oldImage width |
3874 width:oldImage width |
3856 height:oldImage height |
3875 height:oldImage height |
3857 into:newBits |
3876 into:newBits |
3858 mapping:nil |
3877 mapping:nil |
3859 ] ifFalse:[ |
3878 ] ifFalse:[ |
3860 oldBits |
3879 oldBits |
3861 expandPixels:depth |
3880 expandPixels:depth |
3862 width:oldImage width |
3881 width:oldImage width |
3863 height:oldImage height |
3882 height:oldImage height |
3864 into:newBits |
3883 into:newBits |
3865 mapping:oldToNew. |
3884 mapping:oldToNew. |
3866 ]. |
3885 ]. |
3867 |
3886 |
3868 newImage := oldImage species new |
3887 newImage := oldImage species new |
3869 width:oldImage width |
3888 width:oldImage width |
3870 height:oldImage height |
3889 height:oldImage height |
3871 depth:depth |
3890 depth:depth |
3872 fromArray:newBits. |
3891 fromArray:newBits. |
3873 |
3892 |
3874 newImage colorMap:newColorMap. |
3893 newImage colorMap:newColorMap. |
3875 newImage fileName:oldImage fileName. |
3894 newImage fileName:oldImage fileName. |
3876 newImage mask:(oldImage mask copy). |
3895 newImage mask:(oldImage mask copy). |
3877 |
3896 |
3878 ^newImage |
3897 ^newImage |
3879 ! |
3898 ! |
3880 |
3899 |
3881 transparencyTest_primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
3900 transparencyTest_primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
3882 width:imageWidth height:imageHeight |
3901 width:imageWidth height:imageHeight |
3883 into:ignoredDrawableId |
3902 into:ignoredDrawableId |
3884 x:dstx y:dsty |
3903 x:dstx y:dsty |
3885 width:w height:h |
3904 width:w height:h |
3886 with:aGCId |
3905 with:aGCId |
3887 |
3906 |
3888 "since XPutImage may allocate huge amount of stack space |
3907 "since XPutImage may allocate huge amount of stack space |
3889 (some implementations use alloca), this must run with unlimited stack." |
3908 (some implementations use alloca), this must run with unlimited stack." |
3890 |
3909 |
3891 %{ |
3910 %{ |
3929 && __bothSmallInteger(w, h) |
3948 && __bothSmallInteger(w, h) |
3930 && __bothSmallInteger(imageWidth, imageHeight) |
3949 && __bothSmallInteger(imageWidth, imageHeight) |
3931 && __bothSmallInteger(imageDepth, bitsPerPixel) |
3950 && __bothSmallInteger(imageDepth, bitsPerPixel) |
3932 && __imageBits) |
3951 && __imageBits) |
3933 { |
3952 { |
3934 struct |
3953 struct |
3935 { |
3954 { |
3936 BITMAPINFOHEADER bmiHeader; |
3955 BITMAPINFOHEADER bmiHeader; |
3937 RGBQUAD bmiColors[256]; |
3956 RGBQUAD bmiColors[256]; |
3938 } bitmap; |
3957 } bitmap; |
3939 |
3958 |
3940 HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
3959 HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
3941 HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
3960 HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
3942 int col; |
3961 int col; |
3943 /* |
3962 /* |
3944 DDPRINTF(("hDC = %x\n", hDC)); |
3963 DDPRINTF(("hDC = %x\n", hDC)); |
3945 */ |
3964 */ |
3946 |
3965 |
3947 if (padd != WIN32PADDING) { |
3966 if (padd != WIN32PADDING) { |
3948 |
3967 |
3949 int row, col; |
3968 int row, col; |
3950 unsigned char *cp; |
3969 unsigned char *cp; |
3951 unsigned char *pBits; |
3970 unsigned char *pBits; |
3952 int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
3971 int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
3953 int bi = __intVal(bitsPerPixel); |
3972 int bi = __intVal(bitsPerPixel); |
3954 |
3973 |
3955 // console_fprintf(stderr, "Non WIN32PADDING"); |
3974 // console_fprintf(stderr, "Non WIN32PADDING"); |
3956 |
3975 |
3957 b_width = __intVal(w); |
3976 b_width = __intVal(w); |
3958 b_height = __intVal(h); |
3977 b_height = __intVal(h); |
3959 bytesPerRowST = (b_width * bi + (padd - 1 )) / padd; |
3978 bytesPerRowST = (b_width * bi + (padd - 1 )) / padd; |
3960 bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
3979 bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
3961 padding = bytesPerRowWN - bytesPerRowST; |
3980 padding = bytesPerRowWN - bytesPerRowST; |
3962 nBytes = b_height * bytesPerRowWN; |
3981 nBytes = b_height * bytesPerRowWN; |
3963 /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
3982 /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
3964 if (padding) { |
3983 if (padding) { |
3965 if (nBytes < sizeof(fastBits)) { |
3984 if (nBytes < sizeof(fastBits)) { |
3966 cp = b_bits = fastBits; |
3985 cp = b_bits = fastBits; |
3967 } else { |
3986 } else { |
3968 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3987 cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
3969 } |
3988 } |
3970 if (cp) { |
3989 if (cp) { |
3971 pBits = __imageBits; |
3990 pBits = __imageBits; |
3972 for (row = b_height; row; row--) { |
3991 for (row = b_height; row; row--) { |
3973 for (col = bytesPerRowST; col; col--) { |
3992 for (col = bytesPerRowST; col; col--) { |
3974 *cp++ = *pBits++; |
3993 *cp++ = *pBits++; |
3975 } |
3994 } |
3976 cp += padding; |
3995 cp += padding; |
3977 } |
3996 } |
3978 } else |
3997 } else |
3979 goto fail; |
3998 goto fail; |
3980 } |
3999 } |
3981 } |
4000 } |
3982 |
4001 |
3983 if (b_bits == 0) { |
4002 if (b_bits == 0) { |
3984 b_bits = __imageBits; |
4003 b_bits = __imageBits; |
3985 } |
4004 } |
3986 |
4005 |
3987 bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
4006 bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
3988 bitmap.bmiHeader.biPlanes = 1; |
4007 bitmap.bmiHeader.biPlanes = 1; |
3989 bitmap.bmiHeader.biCompression = BI_RGB; |
4008 bitmap.bmiHeader.biCompression = BI_RGB; |
3990 bitmap.bmiHeader.biSizeImage = 0; |
4009 bitmap.bmiHeader.biSizeImage = 0; |
3991 bitmap.bmiHeader.biXPelsPerMeter = 0; |
4010 bitmap.bmiHeader.biXPelsPerMeter = 0; |
3992 bitmap.bmiHeader.biYPelsPerMeter = 0; |
4011 bitmap.bmiHeader.biYPelsPerMeter = 0; |
3993 bitmap.bmiHeader.biClrUsed = 0; |
4012 bitmap.bmiHeader.biClrUsed = 0; |
3994 bitmap.bmiHeader.biClrImportant = 0; |
4013 bitmap.bmiHeader.biClrImportant = 0; |
3995 bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
4014 bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
3996 bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
4015 bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
3997 bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
4016 bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
3998 /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
4017 /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
3999 |
4018 |
4000 if (__intVal(imageDepth) <= 8) { |
4019 if (__intVal(imageDepth) <= 8) { |
4001 for(col=0;col<256;col++) |
4020 for(col=0;col<256;col++) |
4002 { |
4021 { |
4003 bitmap.bmiColors[col].rgbBlue = 0; |
4022 bitmap.bmiColors[col].rgbBlue = 0; |
4004 bitmap.bmiColors[col].rgbGreen = 0; |
4023 bitmap.bmiColors[col].rgbGreen = 0; |
4005 bitmap.bmiColors[col].rgbRed = 0; |
4024 bitmap.bmiColors[col].rgbRed = 0; |
4006 bitmap.bmiColors[col].rgbReserved = 0; |
4025 bitmap.bmiColors[col].rgbReserved = 0; |
4007 |
4026 |
4008 } |
4027 } |
4009 } |
4028 } |
4010 |
4029 |
4011 bitmap.bmiColors[255].rgbBlue=255; |
4030 bitmap.bmiColors[255].rgbBlue=255; |
4012 bitmap.bmiColors[255].rgbGreen=255; |
4031 bitmap.bmiColors[255].rgbGreen=255; |
4013 bitmap.bmiColors[255].rgbRed =255; |
4032 bitmap.bmiColors[255].rgbRed =255; |
4014 bitmap.bmiColors[255].rgbReserved = 0; |
4033 bitmap.bmiColors[255].rgbReserved = 0; |
4015 StretchDIBits(hDC, |
4034 StretchDIBits(hDC, |
4016 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
4035 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
4017 __intVal(w), __intVal(h), // width & height of destination rectangle |
4036 __intVal(w), __intVal(h), // width & height of destination rectangle |
4018 0, 0, /* __intVal(srcx), __intVal(srcy), */ // x & y coord of source upper-left corner |
4037 0, 0, /* __intVal(srcx), __intVal(srcy), */ // x & y coord of source upper-left corner |
4019 __intVal(w), __intVal(h), // width & height of source rectangle |
4038 __intVal(w), __intVal(h), // width & height of source rectangle |
4020 (void *)b_bits, // bitmap bits |
4039 (void *)b_bits, // bitmap bits |
4021 (BITMAPINFO*)&bitmap, // bitmap data |
4040 (BITMAPINFO*)&bitmap, // bitmap data |
4022 DIB_RGB_COLORS, // usage options |
4041 DIB_RGB_COLORS, // usage options |
4023 SRCAND // raster operation code |
4042 SRCAND // raster operation code |
4024 ); |
4043 ); |
4025 /* |
4044 /* |
4026 if (__intVal(imageDepth) <= 8) { |
4045 if (__intVal(imageDepth) <= 8) { |
4027 for(col=0;col<256;col++) |
4046 for(col=0;col<256;col++) |
4028 { |
4047 { |
4029 bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed |
4048 bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed |
4030 bitmap.bmiColors[col].rgbGreen = __greenVector[col]; |
4049 bitmap.bmiColors[col].rgbGreen = __greenVector[col]; |
4031 bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue |
4050 bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue |
4032 bitmap.bmiColors[col].rgbReserved = 0; |
4051 bitmap.bmiColors[col].rgbReserved = 0; |
4033 |
4052 |
4034 } |
4053 } |
4035 } |
4054 } |
4036 |
4055 |
4037 bitmap.bmiColors[255].rgbBlue=0; |
4056 bitmap.bmiColors[255].rgbBlue=0; |
4038 bitmap.bmiColors[255].rgbGreen=0; |
4057 bitmap.bmiColors[255].rgbGreen=0; |
4039 bitmap.bmiColors[255].rgbRed =0; |
4058 bitmap.bmiColors[255].rgbRed =0; |
4040 bitmap.bmiColors[255].rgbReserved = 0; |
4059 bitmap.bmiColors[255].rgbReserved = 0; |
4041 StretchDIBits(hDC, |
4060 StretchDIBits(hDC, |
4042 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
4061 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
4043 __intVal(w), __intVal(h), // width & height of destination rectangle |
4062 __intVal(w), __intVal(h), // width & height of destination rectangle |
4044 0, 0, // x & y coord of source upper-left corner |
4063 0, 0, // x & y coord of source upper-left corner |
4045 __intVal(w), __intVal(h), // width & height of source rectangle |
4064 __intVal(w), __intVal(h), // width & height of source rectangle |
4046 (void *)b_bits, // bitmap bits |
4065 (void *)b_bits, // bitmap bits |
4047 (BITMAPINFO*)&bitmap, // bitmap data |
4066 (BITMAPINFO*)&bitmap, // bitmap data |
4048 DIB_RGB_COLORS, // usage options |
4067 DIB_RGB_COLORS, // usage options |
4049 SRCPAINT // raster operation code |
4068 SRCPAINT // raster operation code |
4050 ); |
4069 ); |
4051 */ |
4070 */ |
4052 /* |
4071 /* |
4053 SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
4072 SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
4054 __intVal(w), __intVal(h), |
4073 __intVal(w), __intVal(h), |
4055 0, 0, |
4074 0, 0, |
4056 0,__intVal(h), |
4075 0,__intVal(h), |
4057 (void *)b_bits, |
4076 (void *)b_bits, |
4058 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
4077 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
4059 */ |
4078 */ |
4060 /* |
4079 /* |
4061 SetDIBits(hDC,hBitmap, |
4080 SetDIBits(hDC,hBitmap, |
4062 0,__intVal(h), |
4081 0,__intVal(h), |
4063 (void *)b_bits, |
4082 (void *)b_bits, |
4064 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
4083 (BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
4065 */ |
4084 */ |
4066 /* |
4085 /* |
4067 StretchDIBits(hDC, |
4086 StretchDIBits(hDC, |
4068 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
4087 __intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
4069 __intVal(w), __intVal(h), // width & height of destination rectangle |
4088 __intVal(w), __intVal(h), // width & height of destination rectangle |
4070 __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
4089 __intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
4071 __intVal(w), __intVal(h), // width & height of source rectangle |
4090 __intVal(w), __intVal(h), // width & height of source rectangle |
4072 (void *)b_bits, // bitmap bits |
4091 (void *)b_bits, // bitmap bits |
4073 (BITMAPINFO*)&bitmap, // bitmap data |
4092 (BITMAPINFO*)&bitmap, // bitmap data |
4074 DIB_RGB_COLORS, // usage options |
4093 DIB_RGB_COLORS, // usage options |
4075 SRCCOPY // raster operation code |
4094 SRCCOPY // raster operation code |
4076 ); |
4095 ); |
4077 */ |
4096 */ |
4078 if (allocatedBits) { |
4097 if (allocatedBits) { |
4079 free(allocatedBits); |
4098 free(allocatedBits); |
4080 } |
4099 } |
4081 /* |
4100 /* |
4082 #ifndef CACHE_LAST_DC |
4101 #ifndef CACHE_LAST_DC |
4083 _releaseDC(gcData); |
4102 _releaseDC(gcData); |
4084 #endif |
4103 #endif |
4085 */ |
4104 */ |
4086 RETURN ( true ); |
4105 RETURN ( true ); |
4087 } |
4106 } |
4088 |
4107 |
4089 fail: ; |
4108 fail: ; |
4090 /* |
4109 /* |
4091 PRINTF(("create temp bitmap FAILED!!!\n")); |
4110 PRINTF(("create temp bitmap FAILED!!!\n")); |
4092 */ |
4111 */ |
4093 if (allocatedBits) { |
4112 if (allocatedBits) { |
4094 /* |
4113 /* |
4095 PRINTF(("freeing up temp bitmap bits ...\n")); |
4114 PRINTF(("freeing up temp bitmap bits ...\n")); |
4096 */ |
4115 */ |
4097 free(allocatedBits); |
4116 free(allocatedBits); |
4098 } |
4117 } |
4099 /* |
4118 /* |
4100 #ifndef CACHE_LAST_DC |
4119 #ifndef CACHE_LAST_DC |
4101 if (hDC) { |
4120 if (hDC) { |
4102 _releaseDC(gcData); |
4121 _releaseDC(gcData); |
4103 } |
4122 } |
4104 #endif |
4123 #endif |
4105 */ |
4124 */ |
4106 %} |
4125 %} |
4107 . |
4126 . |
4207 |
4226 |
4208 styleString := styleArgString. |
4227 styleString := styleArgString. |
4209 |
4228 |
4210 "special: if face is nil, allow access to X-fonts" |
4229 "special: if face is nil, allow access to X-fonts" |
4211 faceString isNil ifTrue:[ |
4230 faceString isNil ifTrue:[ |
4212 sizeArgOrNil notNil ifTrue:[ |
4231 sizeArgOrNil notNil ifTrue:[ |
4213 theName := familyString , '-' , sizeArgOrNil printString |
4232 theName := familyString , '-' , sizeArgOrNil printString |
4214 ] ifFalse:[ |
4233 ] ifFalse:[ |
4215 theName := familyString |
4234 theName := familyString |
4216 ]. |
4235 ]. |
4217 theName notNil ifTrue:[ |
4236 theName notNil ifTrue:[ |
4218 theId := self createFontFor:theName. |
4237 theId := self createFontFor:theName. |
4219 ]. |
4238 ]. |
4220 theId isNil ifTrue:[ |
4239 theId isNil ifTrue:[ |
4221 theId := self getDefaultFontWithEncoding:encodingSym |
4240 theId := self getDefaultFontWithEncoding:encodingSym |
4222 ]. |
4241 ]. |
4223 ^ theId |
4242 ^ theId |
4224 ]. |
4243 ]. |
4225 |
4244 |
4226 "/ spacing other than 'normal' is contained as last component |
4245 "/ spacing other than 'normal' is contained as last component |
4227 "/ in style |
4246 "/ in style |
4228 styleString notNil ifTrue:[ |
4247 styleString notNil ifTrue:[ |
4229 ((styleString endsWith:'-narrow') |
4248 ((styleString endsWith:'-narrow') |
4230 or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
4249 or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
4231 |i| |
4250 |i| |
4232 i := styleString lastIndexOf:$-. |
4251 i := styleString lastIndexOf:$-. |
4233 spacing := styleString copyFrom:(i+1). |
4252 spacing := styleString copyFrom:(i+1). |
4234 styleString := styleString copyTo:(i-1). |
4253 styleString := styleString copyTo:(i-1). |
4235 ] ifFalse:[ |
4254 ] ifFalse:[ |
4236 spacing := 'normal'. |
4255 spacing := 'normal'. |
4237 ]. |
4256 ]. |
4238 ]. |
4257 ]. |
4239 |
4258 |
4240 xlatedStyle := styleString. |
4259 xlatedStyle := styleString. |
4241 xlatedStyle notNil ifTrue:[ |
4260 xlatedStyle notNil ifTrue:[ |
4242 xlatedStyle := xlatedStyle first asString |
4261 xlatedStyle := xlatedStyle first asString |
4243 ]. |
4262 ]. |
4244 |
4263 |
4245 id := self |
4264 id := self |
4246 getFontWithFoundry:'*' |
4265 getFontWithFoundry:'*' |
4247 family:familyString asLowercase |
4266 family:familyString asLowercase |
4248 weight:faceString |
4267 weight:faceString |
4249 slant:styleString "/ xlatedStyle |
4268 slant:styleString "/ xlatedStyle |
4250 spacing:spacing |
4269 spacing:spacing |
4251 pixelSize:nil |
4270 pixelSize:nil |
4252 size:sizeArgOrNil |
4271 size:sizeArgOrNil |
4253 registry:'*' |
4272 registry:'*' |
4254 encoding:encodingSym. |
4273 encoding:encodingSym. |
4255 |
4274 |
4256 id isNil ifTrue:[ |
4275 id isNil ifTrue:[ |
4257 (encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
4276 (encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
4258 "/ too stupid: encodings come in both cases |
4277 "/ too stupid: encodings come in both cases |
4259 "/ |
4278 "/ |
4260 id := self |
4279 id := self |
4261 getFontWithFoundry:'*' |
4280 getFontWithFoundry:'*' |
4262 family:familyString asLowercase |
4281 family:familyString asLowercase |
4263 weight:faceString |
4282 weight:faceString |
4264 slant:styleString "/ xlatedStyle |
4283 slant:styleString "/ xlatedStyle |
4265 spacing:spacing |
4284 spacing:spacing |
4266 pixelSize:nil |
4285 pixelSize:nil |
4267 size:sizeArgOrNil |
4286 size:sizeArgOrNil |
4268 registry:'*' |
4287 registry:'*' |
4269 encoding:encodingSym asUppercase. |
4288 encoding:encodingSym asUppercase. |
4270 id isNil ifTrue:[ |
4289 id isNil ifTrue:[ |
4271 id := self |
4290 id := self |
4272 getFontWithFoundry:'*' |
4291 getFontWithFoundry:'*' |
4273 family:familyString asLowercase |
4292 family:familyString asLowercase |
4274 weight:faceString |
4293 weight:faceString |
4275 slant:styleString "/ xlatedStyle |
4294 slant:styleString "/ xlatedStyle |
4276 spacing:spacing |
4295 spacing:spacing |
4277 pixelSize:nil |
4296 pixelSize:nil |
4278 size:sizeArgOrNil |
4297 size:sizeArgOrNil |
4279 registry:'*' |
4298 registry:'*' |
4280 encoding:encodingSym asLowercase. |
4299 encoding:encodingSym asLowercase. |
4281 |
4300 |
4282 id isNil ifTrue:[ |
4301 id isNil ifTrue:[ |
4283 id := self |
4302 id := self |
4284 getFontWithFoundry:'*' |
4303 getFontWithFoundry:'*' |
4285 family:familyString asLowercase |
4304 family:familyString asLowercase |
4286 weight:faceString asLowercase |
4305 weight:faceString asLowercase |
4287 slant:styleString asLowercase |
4306 slant:styleString asLowercase |
4288 spacing:spacing |
4307 spacing:spacing |
4289 pixelSize:nil |
4308 pixelSize:nil |
4290 size:sizeArgOrNil |
4309 size:sizeArgOrNil |
4291 registry:'*' |
4310 registry:'*' |
4292 encoding:encodingSym asLowercase. |
4311 encoding:encodingSym asLowercase. |
4293 ] |
4312 ] |
4294 ] |
4313 ] |
4295 ] |
4314 ] |
4296 ]. |
4315 ]. |
4297 ^ id |
4316 ^ id |
4298 |
4317 |
4299 "Modified: 24.2.1996 / 22:37:24 / cg" |
4318 "Modified: 24.2.1996 / 22:37:24 / cg" |
4300 "Modified: 4.7.1996 / 11:38:47 / stefan" |
4319 "Modified: 4.7.1996 / 11:38:47 / stefan" |
4301 ! |
4320 ! |
4302 |
4321 |
4303 getFontWithFoundry:foundry family:family weight:weight |
4322 getFontWithFoundry:foundry family:family weight:weight |
4304 slant:slant spacing:spc pixelSize:pixelSize size:pointSize |
4323 slant:slant spacing:spc pixelSize:pixelSize size:pointSize |
4305 registry:registry encoding:encodingArg |
4324 registry:registry encoding:encodingArg |
4306 |
4325 |
4307 "get the specified font, if not available, return nil. |
4326 "get the specified font, if not available, return nil. |
4308 For now, this is a poor (incomplete) emulation of the X code ... |
4327 For now, this is a poor (incomplete) emulation of the X code ... |
4309 Individual attributes can be left empty (i.e. '') or nil to match any. |
4328 Individual attributes can be left empty (i.e. '') or nil to match any. |
4310 |
4329 |
4320 " |
4339 " |
4321 |
4340 |
4322 " |
4341 " |
4323 Windows-NT/95 allows the creation of a font with the following parameters |
4342 Windows-NT/95 allows the creation of a font with the following parameters |
4324 |
4343 |
4325 nHeight |
4344 nHeight |
4326 nWidth |
4345 nWidth |
4327 nEscapement |
4346 nEscapement |
4328 nOrientation |
4347 nOrientation |
4329 fnWeight FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ... |
4348 fnWeight FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ... |
4330 fdwItalic TRUE or FALSE |
4349 fdwItalic TRUE or FALSE |
4331 fdwUnderline TRUE or FALSE |
4350 fdwUnderline TRUE or FALSE |
4332 fdwStrikeOut TRUE or FALSE |
4351 fdwStrikeOut TRUE or FALSE |
4333 fdwCharSet ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,... |
4352 fdwCharSet ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,... |
4334 fdwOutputPrecision DEFAULT, STRING, CHAR, ... |
4353 fdwOutputPrecision DEFAULT, STRING, CHAR, ... |
4335 fdwClipPrecision DEFAULT, CHAR, STROKE, MASK, ... |
4354 fdwClipPrecision DEFAULT, CHAR, STROKE, MASK, ... |
4336 fdwQuality DEFAULT, DRAFT, or PROOF. |
4355 fdwQuality DEFAULT, DRAFT, or PROOF. |
4337 fdwPitchAndFamily |
4356 fdwPitchAndFamily |
4338 DEFAULT, FIXED or VARIABLE pitch |
4357 DEFAULT, FIXED or VARIABLE pitch |
4339 DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS. |
4358 DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS. |
4340 lpszFace |
4359 lpszFace |
4341 Typeface Name |
4360 Typeface Name |
4342 |
4361 |
4343 These two above descriptions will be matched as follows: |
4362 These two above descriptions will be matched as follows: |
4344 |
4363 |
4345 foundry - ignored |
4364 foundry - ignored |
4346 family - mapped to type face name. |
4365 family - mapped to type face name. |
4347 weight - mapped to fnWeight |
4366 weight - mapped to fnWeight |
4348 slant - used for style |
4367 slant - used for style |
4349 spacing - NOT USED INITIALLY |
4368 spacing - NOT USED INITIALLY |
4350 pixelSize - NOT USED INITIALLY |
4369 pixelSize - NOT USED INITIALLY |
4351 size - mapped to nHeight |
4370 size - mapped to nHeight |
4352 registry - NOT USED INITIALLY |
4371 registry - NOT USED INITIALLY |
4353 encoding - mapped to fdwCharSet |
4372 encoding - mapped to fdwCharSet |
4354 " |
4373 " |
4355 |
4374 |
4356 |logSize encoding| |
4375 |logSize encoding| |
4357 |
4376 |
4358 encoding := encodingArg asSymbol. |
4377 encoding := encodingArg asSymbol. |
4359 |
4378 |
4360 pixelSize notNil ifTrue:[ |
4379 pixelSize notNil ifTrue:[ |
4361 logSize := pixelSize |
4380 logSize := pixelSize |
4362 ] ifFalse:[ |
4381 ] ifFalse:[ |
4363 logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded. |
4382 logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded. |
4364 ]. |
4383 ]. |
4365 %{ |
4384 %{ |
4366 HGDIOBJ hFont; |
4385 HGDIOBJ hFont; |
4367 int pointSize, nHeight, nWidth, nEscapement, nOrientation; |
4386 int nHeight, nWidth, nEscapement, nOrientation; |
4368 char* work; |
4387 char* work; |
4369 char* work2; |
4388 char* work2; |
4370 DWORD fnWeight; |
4389 DWORD fnWeight; |
4371 DWORD fdwItalic; |
4390 DWORD fdwItalic; |
4372 DWORD fdwUnderline; |
4391 DWORD fdwUnderline; |
4393 fdwQuality = DEFAULT_QUALITY; |
4412 fdwQuality = DEFAULT_QUALITY; |
4394 fdwPitchAndFamily = FF_DONTCARE; |
4413 fdwPitchAndFamily = FF_DONTCARE; |
4395 |
4414 |
4396 fdwCharSet = ANSI_CHARSET; |
4415 fdwCharSet = ANSI_CHARSET; |
4397 if ((encoding == @symbol('ms-ansi'))) { |
4416 if ((encoding == @symbol('ms-ansi'))) { |
4398 fdwCharSet = ANSI_CHARSET; |
4417 fdwCharSet = ANSI_CHARSET; |
4399 } else if (encoding == @symbol('ms-default') |
4418 } else if (encoding == @symbol('ms-default') |
4400 || encoding == @symbol(*)) { |
4419 || encoding == @symbol(*)) { |
4401 fdwCharSet = DEFAULT_CHARSET; |
4420 fdwCharSet = DEFAULT_CHARSET; |
4402 } else if ((encoding == @symbol('ms-symbol')) |
4421 } else if ((encoding == @symbol('ms-symbol')) |
4403 || (encoding == @symbol('misc-fontspecific'))) { |
4422 || (encoding == @symbol('misc-fontspecific'))) { |
4404 fdwCharSet = SYMBOL_CHARSET; |
4423 fdwCharSet = SYMBOL_CHARSET; |
4405 } else if ((encoding == @symbol('ms-shiftjis')) |
4424 } else if ((encoding == @symbol('ms-shiftjis')) |
4406 || (encoding == @symbol('jisx0208.1983-0'))){ |
4425 || (encoding == @symbol('jisx0208.1983-0'))){ |
4407 fdwCharSet = SHIFTJIS_CHARSET; |
4426 fdwCharSet = SHIFTJIS_CHARSET; |
4408 } else if ((encoding == @symbol('ms-gb2312')) |
4427 } else if ((encoding == @symbol('ms-gb2312')) |
4409 || (encoding == @symbol('gb2312.1980-0'))) { |
4428 || (encoding == @symbol('gb2312.1980-0'))) { |
4410 fdwCharSet = GB2312_CHARSET; |
4429 fdwCharSet = GB2312_CHARSET; |
4411 } else if ((encoding == @symbol('ms-hangeul')) |
4430 } else if ((encoding == @symbol('ms-hangeul')) |
4412 || (encoding == @symbol('ksc5601.1987-0'))) { |
4431 || (encoding == @symbol('ksc5601.1987-0'))) { |
4413 fdwCharSet = HANGEUL_CHARSET; |
4432 fdwCharSet = HANGEUL_CHARSET; |
4414 } else if ((encoding == @symbol('ms-chinesebig5')) |
4433 } else if ((encoding == @symbol('ms-chinesebig5')) |
4415 || (encoding == @symbol('big5'))) { |
4434 || (encoding == @symbol('big5'))) { |
4416 fdwCharSet = CHINESEBIG5_CHARSET; |
4435 fdwCharSet = CHINESEBIG5_CHARSET; |
4417 } else if (encoding == @symbol('ms-oem')) { |
4436 } else if (encoding == @symbol('ms-oem')) { |
4418 fdwCharSet = OEM_CHARSET; |
4437 fdwCharSet = OEM_CHARSET; |
4419 } else if (encoding == @symbol('ms-johab')) { |
4438 } else if (encoding == @symbol('ms-johab')) { |
4420 fdwCharSet = JOHAB_CHARSET; |
4439 fdwCharSet = JOHAB_CHARSET; |
4421 } else if ((encoding == @symbol('ms-hebrew')) |
4440 } else if ((encoding == @symbol('ms-hebrew')) |
4422 || (encoding == @symbol('ms-cp1255'))) { |
4441 || (encoding == @symbol('ms-cp1255'))) { |
4423 fdwCharSet = HEBREW_CHARSET; |
4442 fdwCharSet = HEBREW_CHARSET; |
4424 } else if ((encoding == @symbol('ms-arabic')) |
4443 } else if ((encoding == @symbol('ms-arabic')) |
4425 || (encoding == @symbol('ms-cp1256'))) { |
4444 || (encoding == @symbol('ms-cp1256'))) { |
4426 fdwCharSet = ARABIC_CHARSET; |
4445 fdwCharSet = ARABIC_CHARSET; |
4427 } else if ((encoding == @symbol('ms-greek')) |
4446 } else if ((encoding == @symbol('ms-greek')) |
4428 || (encoding == @symbol('ms-cp1253'))) { |
4447 || (encoding == @symbol('ms-cp1253'))) { |
4429 fdwCharSet = GREEK_CHARSET; |
4448 fdwCharSet = GREEK_CHARSET; |
4430 } else if ((encoding == @symbol('ms-turkish')) |
4449 } else if ((encoding == @symbol('ms-turkish')) |
4431 || (encoding == @symbol('ms-cp1254'))) { |
4450 || (encoding == @symbol('ms-cp1254'))) { |
4432 fdwCharSet = TURKISH_CHARSET; |
4451 fdwCharSet = TURKISH_CHARSET; |
4433 } else if ((encoding == @symbol('ms-russian')) |
4452 } else if ((encoding == @symbol('ms-russian')) |
4434 || (encoding == @symbol('ms-cp1251'))) { |
4453 || (encoding == @symbol('ms-cp1251'))) { |
4435 fdwCharSet = RUSSIAN_CHARSET; |
4454 fdwCharSet = RUSSIAN_CHARSET; |
4436 } else if ((encoding == @symbol('ms-easteurope')) |
4455 } else if ((encoding == @symbol('ms-easteurope')) |
4437 || (encoding == @symbol('ms-cp1250'))) { |
4456 || (encoding == @symbol('ms-cp1250'))) { |
4438 fdwCharSet = EASTEUROPE_CHARSET; |
4457 fdwCharSet = EASTEUROPE_CHARSET; |
4439 } else if ((encoding == @symbol('ms-baltic')) |
4458 } else if ((encoding == @symbol('ms-baltic')) |
4440 || (encoding == @symbol('ms-cp1257'))) { |
4459 || (encoding == @symbol('ms-cp1257'))) { |
4441 fdwCharSet = BALTIC_CHARSET; |
4460 fdwCharSet = BALTIC_CHARSET; |
4442 } else if ((encoding == @symbol('ms-vietnamese'))) { |
4461 } else if ((encoding == @symbol('ms-vietnamese'))) { |
4443 fdwCharSet = VIETNAMESE_CHARSET; |
4462 fdwCharSet = VIETNAMESE_CHARSET; |
4444 } else if ((encoding == @symbol('ms-thai'))) { |
4463 } else if ((encoding == @symbol('ms-thai'))) { |
4445 fdwCharSet = THAI_CHARSET; |
4464 fdwCharSet = THAI_CHARSET; |
4446 } else if ((encoding == @symbol('ms-mac'))) { |
4465 } else if ((encoding == @symbol('ms-mac'))) { |
4447 fdwCharSet = MAC_CHARSET; |
4466 fdwCharSet = MAC_CHARSET; |
4448 #ifdef UNICODE_CHARSET |
4467 #ifdef UNICODE_CHARSET |
4449 } else if ((encoding == @symbol('ms-unicode'))) { |
4468 } else if ((encoding == @symbol('ms-unicode'))) { |
4450 fdwCharSet = UNICODE_CHARSET; |
4469 fdwCharSet = UNICODE_CHARSET; |
4451 #endif |
4470 #endif |
4452 } |
4471 } |
4453 |
4472 |
4454 if ( __isString( family ) ) { |
4473 if ( __isString( family ) ) { |
4455 work = __stringVal( family ); |
4474 work = __stringVal( family ); |
4456 if (strcmp( work, "nil" ) != 0 ) { |
4475 if (strcmp( work, "nil" ) != 0 ) { |
4457 strncpy( faceName, work, sizeof(faceName)-1 ); |
4476 strncpy( faceName, work, sizeof(faceName)-1 ); |
4458 } |
4477 } |
4459 } |
4478 } |
4460 |
4479 |
4461 /* Q: should we allow those ? (they make ST/X programs less portable to X */ |
4480 /* Q: should we allow those ? (they make ST/X programs less portable to X */ |
4462 if( __isString( weight ) ) { |
4481 if( __isString( weight ) ) { |
4463 work = __stringVal( weight ); |
4482 work = __stringVal( weight ); |
4464 if (strcmp( work, "bold" ) == 0 ) { |
4483 if (strcmp( work, "bold" ) == 0 ) { |
4465 fnWeight = FW_BOLD; |
4484 fnWeight = FW_BOLD; |
4466 } else if (strcmp( work, "medium" ) == 0 ) { |
4485 } else if (strcmp( work, "medium" ) == 0 ) { |
4467 fnWeight = FW_MEDIUM; |
4486 fnWeight = FW_MEDIUM; |
4468 } else if (strcmp( work, "normal" ) == 0 ) { |
4487 } else if (strcmp( work, "normal" ) == 0 ) { |
4469 fnWeight = FW_NORMAL; |
4488 fnWeight = FW_NORMAL; |
4470 } else if (strcmp( work, "light" ) == 0 ) { |
4489 } else if (strcmp( work, "light" ) == 0 ) { |
4471 fnWeight = FW_LIGHT; |
4490 fnWeight = FW_LIGHT; |
4472 } else if (strcmp( work, "demi" ) == 0 ) { |
4491 } else if (strcmp( work, "demi" ) == 0 ) { |
4473 fnWeight = FW_LIGHT; |
4492 fnWeight = FW_LIGHT; |
4474 } else if (strcmp( work, "heavy" ) == 0 ) { |
4493 } else if (strcmp( work, "heavy" ) == 0 ) { |
4475 fnWeight = FW_HEAVY; |
4494 fnWeight = FW_HEAVY; |
4476 } else if (strcmp( work, "extraBold" ) == 0 ) { |
4495 } else if (strcmp( work, "extraBold" ) == 0 ) { |
4477 fnWeight = FW_EXTRABOLD; |
4496 fnWeight = FW_EXTRABOLD; |
4478 } else if (strcmp( work, "semiBold" ) == 0 ) { |
4497 } else if (strcmp( work, "semiBold" ) == 0 ) { |
4479 fnWeight = FW_SEMIBOLD; |
4498 fnWeight = FW_SEMIBOLD; |
4480 } else if (strcmp( work, "thin" ) == 0 ) { |
4499 } else if (strcmp( work, "thin" ) == 0 ) { |
4481 fnWeight = FW_THIN; |
4500 fnWeight = FW_THIN; |
4482 } else if (strcmp( work, "extraLight" ) == 0 ) { |
4501 } else if (strcmp( work, "extraLight" ) == 0 ) { |
4483 fnWeight = FW_EXTRALIGHT; |
4502 fnWeight = FW_EXTRALIGHT; |
4484 } |
4503 } |
4485 } else if (__isSmallInteger(weight)) { |
4504 } else if (__isSmallInteger(weight)) { |
4486 fnWeight = __intVal(weight); |
4505 fnWeight = __intVal(weight); |
4487 } |
4506 } |
4488 |
4507 |
4489 if(__isSmallInteger( logSize )) { |
4508 if(__isSmallInteger( logSize )) { |
4490 nHeight = __intVal( logSize ); |
4509 nHeight = __intVal( logSize ); |
4491 } |
4510 } |
4492 |
4511 |
4493 if (__isString(slant)) { |
4512 if (__isString(slant)) { |
4494 work2 = __stringVal( slant ); |
4513 work2 = __stringVal( slant ); |
4495 work = __stringVal( slant ); |
4514 work = __stringVal( slant ); |
4496 |
4515 |
4497 if (strncmp(work2, "italic", 6) == 0) { |
4516 if (strncmp(work2, "italic", 6) == 0) { |
4498 fdwItalic = TRUE; |
4517 fdwItalic = TRUE; |
4499 if ( work2[6] == '-' ) |
4518 if ( work2[6] == '-' ) |
4500 strncpy( work, &work2[7], ( strlen( work2) - 7) ); |
4519 strncpy( work, &work2[7], ( strlen( work2) - 7) ); |
4501 } else { |
4520 } else { |
4502 if (strncmp(work2, "oblique", 7) == 0) { |
4521 if (strncmp(work2, "oblique", 7) == 0) { |
4503 fdwItalic = TRUE; |
4522 fdwItalic = TRUE; |
4504 if ( work2[7] == '-' ) |
4523 if ( work2[7] == '-' ) |
4505 strncpy( work, &work2[8], ( strlen( work2) - 8) ); |
4524 strncpy( work, &work2[8], ( strlen( work2) - 8) ); |
4506 } |
4525 } |
4507 } |
4526 } |
4508 if (strncmp( work, "underline", 9 ) == 0 ) { |
4527 if (strncmp( work, "underline", 9 ) == 0 ) { |
4509 fdwUnderline = TRUE; |
4528 fdwUnderline = TRUE; |
4510 if( work[10] == '-' ) |
4529 if( work[10] == '-' ) |
4511 strncpy( work2, &work[11], ( strlen( work ) - 10 ) ); |
4530 strncpy( work2, &work[11], ( strlen( work ) - 10 ) ); |
4512 } |
4531 } |
4513 if (strncmp( work2, "strikeOut", 9 ) == 0 ) { |
4532 if (strncmp( work2, "strikeOut", 9 ) == 0 ) { |
4514 fdwStrikeOut = TRUE; |
4533 fdwStrikeOut = TRUE; |
4515 } |
4534 } |
4516 } |
4535 } |
4517 |
4536 |
4518 DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n", |
4537 DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n", |
4519 faceName, nHeight, nWidth, fnWeight)); |
4538 faceName, nHeight, nWidth, fnWeight)); |
4520 |
4539 |
4521 hFont = CreateFont( -nHeight, /* character height - not cell height */ |
4540 hFont = CreateFont( -nHeight, /* character height - not cell height */ |
4522 nWidth, |
4541 nWidth, |
4523 nEscapement, |
4542 nEscapement, |
4524 nOrientation, |
4543 nOrientation, |
4525 fnWeight, |
4544 fnWeight, |
4526 fdwItalic, |
4545 fdwItalic, |
4527 fdwUnderline, |
4546 fdwUnderline, |
4528 fdwStrikeOut, |
4547 fdwStrikeOut, |
4529 fdwCharSet, |
4548 fdwCharSet, |
4530 fdwOutputPrecision, |
4549 fdwOutputPrecision, |
4531 fdwClipPrecision, |
4550 fdwClipPrecision, |
4532 fdwQuality, |
4551 fdwQuality, |
4533 fdwPitchAndFamily, |
4552 fdwPitchAndFamily, |
4534 faceName ); |
4553 faceName ); |
4535 |
4554 |
4536 if (hFont != NULL) { |
4555 if (hFont != NULL) { |
4537 DPRINTF(("createFont: %x\n", hFont)); |
4556 DPRINTF(("createFont: %x\n", hFont)); |
4538 /* |
4557 /* |
4539 #ifdef COUNT_RESOURCES |
4558 #ifdef COUNT_RESOURCES |
4540 __cnt_font++; |
4559 __cnt_font++; |
4541 RES1PRINTF(("CreateFont %d\n", __cnt_font)); |
4560 RES1PRINTF(("CreateFont %d\n", __cnt_font)); |
4542 #endif |
4561 #endif |
4543 */ |
4562 */ |
4544 RETURN ( __MKEXTERNALADDRESS(hFont) ); |
4563 RETURN ( __MKEXTERNALADDRESS(hFont) ); |
4545 } |
4564 } |
4546 |
4565 |
4547 DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" )); |
4566 DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" )); |
4548 %}. |
4567 %}. |
4549 ^ nil |
4568 ^ nil |
4550 |
4569 |
4551 " |
4570 " |
4552 Display getFontWithFoundry:'*' |
4571 Display getFontWithFoundry:'*' |
4553 family:'courier' |
4572 family:'courier' |
4554 weight:'medium' |
4573 weight:'medium' |
4555 slant:'r' |
4574 slant:'r' |
4556 spacing:nil |
4575 spacing:nil |
4557 pixelSize:nil |
4576 pixelSize:nil |
4558 size:13 |
4577 size:13 |
4559 registry:'iso8859' |
4578 registry:'iso8859' |
4560 encoding:'*' |
4579 encoding:'*' |
4561 " |
4580 " |
4562 |
4581 |
4563 "new NT Version: 20.2.1997 / 22:33:29 / dq" |
4582 "new NT Version: 20.2.1997 / 22:33:29 / dq" |
4564 ! |
4583 ! |
4565 |
4584 |
5026 gcForBitmap:aDrawableId |
5045 gcForBitmap:aDrawableId |
5027 |
5046 |
5028 %{ /* NOCONTEXT */ |
5047 %{ /* NOCONTEXT */ |
5029 |
5048 |
5030 if (__isExternalAddress(aDrawableId)){ |
5049 if (__isExternalAddress(aDrawableId)){ |
5031 BITMAP bitmap; |
5050 BITMAP bitmap; |
5032 HBITMAP hBitmap = _HBITMAPVAL(aDrawableId); |
5051 HBITMAP hBitmap = _HBITMAPVAL(aDrawableId); |
5033 HBITMAP memBM; |
5052 HBITMAP memBM; |
5034 HANDLE compatibleDC, rootDC, hdcScreen; |
5053 HANDLE compatibleDC, rootDC, hdcScreen; |
5035 // HANDLE printerDC = (HANDLE)(__externalAddressVal(__INST(gcId))); |
5054 // HANDLE printerDC = (HANDLE)(__externalAddressVal(__INST(gcId))); |
5036 |
5055 |
5037 if (! hBitmap) { |
5056 if (! hBitmap) { |
5038 RETURN (nil); |
5057 RETURN (nil); |
5039 } |
5058 } |
5040 |
5059 |
5041 if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) { |
5060 if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) { |
5042 /* |
5061 /* |
5043 DDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel)); |
5062 DDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel)); |
5044 */ |
5063 */ |
5045 } else { |
5064 } else { |
5046 /* |
5065 /* |
5047 DPRINTF(("noinfo returned for bitmap\n")); |
5066 DPRINTF(("noinfo returned for bitmap\n")); |
5048 */ |
5067 */ |
5049 /* mhmh - can this happen ? */ |
5068 /* mhmh - can this happen ? */ |
5050 bitmap.bmBitsPixel = 1; |
5069 bitmap.bmBitsPixel = 1; |
5051 } |
5070 } |
5052 /* |
5071 /* |
5053 gcData->hBitmap = hBitmap; |
5072 gcData->hBitmap = hBitmap; |
5054 gcData->bitmapColorBitCount = bitmap.bmBitsPixel; |
5073 gcData->bitmapColorBitCount = bitmap.bmBitsPixel; |
5055 */ |
5074 */ |
5056 |
5075 |
5057 rootDC = CreateDC("DISPLAY", NULL, NULL, NULL); |
5076 rootDC = CreateDC("DISPLAY", NULL, NULL, NULL); |
5058 compatibleDC = CreateCompatibleDC(rootDC); |
5077 compatibleDC = CreateCompatibleDC(rootDC); |
5059 SelectObject(compatibleDC, hBitmap); |
5078 SelectObject(compatibleDC, hBitmap); |
5060 |
5079 |
5061 // hdcScreen= CreateDC("NULL", NULL, NULL, NULL); |
5080 // hdcScreen= CreateDC("NULL", NULL, NULL, NULL); |
5062 // compatibleDC = rootDC; |
5081 // compatibleDC = rootDC; |
5063 // compatibleDC = CreateCompatibleDC(printerDC); |
5082 // compatibleDC = CreateCompatibleDC(printerDC); |
5064 // compatibleDC = CreateCompatibleDC(0); |
5083 // compatibleDC = CreateCompatibleDC(0); |
5065 |
5084 |
5066 // memBM = CreateCompatibleBitmap ( compatibleDC, bitmap.bmWidth, bitmap.bmHeight ); |
5085 // memBM = CreateCompatibleBitmap ( compatibleDC, bitmap.bmWidth, bitmap.bmHeight ); |
5067 // SelectObject ( compatibleDC, memBM ); |
5086 // SelectObject ( compatibleDC, memBM ); |
5068 |
5087 |
5069 RETURN (__MKEXTERNALADDRESS(compatibleDC)); |
5088 RETURN (__MKEXTERNALADDRESS(compatibleDC)); |
5070 |
5089 |
5071 /* |
5090 /* |
5072 RETURN ( __MKEXTERNALADDRESS(gcData) ); |
5091 RETURN ( __MKEXTERNALADDRESS(gcData) ); |
5073 */ |
5092 */ |
5074 } |
5093 } |
5075 RETURN (nil); |
5094 RETURN (nil); |
5076 %} |
5095 %} |
5077 ! |
5096 ! |
5867 |
5886 |
5868 metrics := super fontMetricsOf:fontId. |
5887 metrics := super fontMetricsOf:fontId. |
5869 metrics isNil ifTrue:[^ nil ]. |
5888 metrics isNil ifTrue:[^ nil ]. |
5870 |
5889 |
5871 metrics ascent:((metrics ascent / fontScale y) rounded) |
5890 metrics ascent:((metrics ascent / fontScale y) rounded) |
5872 descent:((metrics descent / fontScale y) rounded + 1) |
5891 descent:((metrics descent / fontScale y) rounded + 1) |
5873 maxAscent:((metrics maxAscent / fontScale y) rounded) |
5892 maxAscent:((metrics maxAscent / fontScale y) rounded) |
5874 maxDescent:((metrics maxDescent / fontScale y) rounded + 1) |
5893 maxDescent:((metrics maxDescent / fontScale y) rounded + 1) |
5875 minWidth:((metrics minWidth / fontScale x) rounded) |
5894 minWidth:((metrics minWidth / fontScale x) rounded) |
5876 maxWidth:((metrics maxWidth / fontScale x) rounded) |
5895 maxWidth:((metrics maxWidth / fontScale x) rounded) |
5877 avgWidth:((metrics averageWidth / fontScale x) rounded). |
5896 avgWidth:((metrics averageWidth / fontScale x) rounded). |
5878 |
5897 |
5879 ^ metrics |
5898 ^ metrics |
5880 ! |
5899 ! |
5881 |
5900 |
5882 getFontWithFoundry:foundry family:family weight:weight |
5901 getFontWithFoundry:foundry family:family weight:weight |
5883 slant:slant spacing:spc pixelSize:pixelSize size:pointSize |
5902 slant:slant spacing:spc pixelSize:pixelSize size:pointSize |
5884 registry:registry encoding:encoding |
5903 registry:registry encoding:encoding |
5885 |
5904 |
5886 "compute the pixels dependent on the Screen current resolution" |
5905 "compute the pixels dependent on the Screen current resolution" |
5887 |
5906 |
5888 |psize| |
5907 |psize| |
5889 |
5908 |
5890 psize := pixelSize. |
5909 psize := pixelSize. |
5891 |
5910 |
5892 psize isNil ifTrue:[ |
5911 psize isNil ifTrue:[ |
5893 psize := (pointSize * (self getLogicalPixelSizeY) / (Screen current getLogicalPixelSizeY)) rounded. |
5912 psize := (pointSize * (self getLogicalPixelSizeY) / (Screen current getLogicalPixelSizeY)) rounded. |
5894 ]. |
5913 ]. |
5895 |
5914 |
5896 ^ super getFontWithFoundry:foundry family:family weight:weight |
5915 ^ super getFontWithFoundry:foundry family:family weight:weight |
5897 slant:slant spacing:spc pixelSize:psize size:pointSize |
5916 slant:slant spacing:spc pixelSize:psize size:pointSize |
5898 registry:registry encoding:encoding |
5917 registry:registry encoding:encoding |
5899 ! |
5918 ! |
5900 |
5919 |
5901 titleFont |
5920 titleFont |
5902 "answer the font used for displaying page numbers..." |
5921 "answer the font used for displaying page numbers..." |
5903 |
5922 |
5904 titleFont isNil ifTrue:[ |
5923 titleFont isNil ifTrue:[ |
5905 titleFont := Font family:'helvetica' face:'medium' style:'roman' size:10. |
5924 titleFont := Font family:'helvetica' face:'medium' style:'roman' size:10. |
5906 titleFont := titleFont onDevice:(self device). |
5925 titleFont := titleFont onDevice:(self device). |
5907 ]. |
5926 ]. |
5908 ^ titleFont |
5927 ^ titleFont |
5909 ! |
5928 ! |
5910 |
5929 |
5911 titleFont:aFont |
5930 titleFont:aFont |
5912 "set the font used for displaying page numbers..." |
5931 "set the font used for displaying page numbers..." |
5913 |
5932 |
5914 (aFont notNil and:[aFont ~= titleFont]) ifTrue:[ |
5933 (aFont notNil and:[aFont ~= titleFont]) ifTrue:[ |
5915 titleFont := aFont onDevice:(self device). |
5934 titleFont := aFont onDevice:(self device). |
5916 ]. |
5935 ]. |
5917 ! |
5936 ! |
5918 |
5937 |
5919 widthOf:aString from:index1 to:index2 inFont:aFontId |
5938 widthOf:aString from:index1 to:index2 inFont:aFontId |
5920 "after retrieving the width, we have to scale the width" |
5939 "after retrieving the width, we have to scale the width" |