Mike Schaeffer's Blog

Articles with tag: graphics
January 27, 2006

Reading Cyrille Berger's blog has been quite interesting lately. He's been slowly plugging away at adding features to Krita, KDE's graphics editor. Krita now has 16-bit color, HDR images, CMYK color space, as well as LAB color. This is stuff that Gimp won't do until GEGL is ready and integrated. Maybe it's time to start dual booting Linux again...

November 16, 2005

A few months ago I wrote a bit on the impact of high resolution displays on the way Internet Explorer renders graphics. I had really planned on using the default setting. Not anymore!

This is the awful default:

This is as it should be:

Now, guess what Firefox does.

October 11, 2005

David Gainer has Summarized a a number of new conditional formatting rules in Excel 12, over on the Excel 12 blog. These rules were designed to "make a greater number of scenarios possible without needing to write formulas." In other words, all these scenarios have simple solutions directly visible in the Excel 12 UI.

Well, if you can't wait for Excel 12, Excel is pretty darned powerful as it is, and as Mr. Gainer states: most of these scenarios have formula-based approaches that work right now. Here are some of the approaches for current versions of Excel:

  • With data bars, color scales, or icons based on the numeric value in the cell, percentages, percentiles, or a formula. See the posts on data bars, color scales, and icon sets for more information on each of these. - This approach to 'databars' generalizes to formula-based scaling, although it's not as pretty, not a color scale, and not an icon set.
  • Containing, not containing, beginning with, or ending with specific text. For example, highlighting parts containing certain characters in a parts catalog. - Use a formula: a lot of these conditions can be tested using FIND: =FIND(string, A1)=1, checks for parts that begin with string, for example.
  • Containing dates that match dynamic conditions like yesterday, today, tomorrow, in the last 7 days, last week, this week, next week, last month, this month, next month. For example, highlight all items dated yesterday. The great part about these conditions is that Excel handles calculating the date based on the system clock, so the user doesn.t need to worry about updating the condition. - Use a formula: the system date is available via NOW(), and Excel offers plenty of date arithmetic functions to check for specific conditions.
  • That are blank or that are non-blank. - Use a formula: =ISBLANK(A1) or =NOT(ISBLANK(A1))
  • That have errors or that do not have errors. - Use a formula: =ISERROR(A1) or =NOT(ISERROR(A1))
  • That are in the top n of a selected range (where n is whatever number you want) OR that are in the top n percent of a selected range (again, where n is adjustable). For example, highlighting the top 10 investment returns in a table of 1,000 investments. - Use a formula: =RANK(A1, range) > n.
  • Cells that have the bottom n values OR cells that are the bottom n percent of a selected range. - Use a formula: `=RANK(A1, range)n`.
  • Cells that are above average, below average, equal to or above average, equal to or below average, 1 standard deviation above, 1 standard deviation below, 2 standard deviations above, 2 standard deviations below, 3 standard deviations above, 3 standard deviations below a selected range. - This type of thing can be solved using a particular form of formula: =A1<(AVERAGE(ange)-n*STDEV(range)) or =A1>(AVERAGE(ange)+n*STDEV(range)). For large ranges, it probably makes sense to move the computation of AVERAGE and STDEV into a cell, and have the conditional format reference (with an absolute reference) that cell.
  • Cells that are duplicate values or, conversely, cells that are unique values. - Use a formula: =COUNTIF(range, A1)=1 or =COUNTIF(range, A1)>1. Ensure that the range you use in the formula has an absolute address. If your range is sorted on the 'key' field, you can use this style of formula: =A1<>A2. This can be much, much faster, particularly for large tables. (For the Comp. Sci. types it's O(N), rather than O(N2 ), once you have sorted data.)
  • Based on comparisons between two columns in tables. For example, highlight values where values in the .Actual Sales. column are less than in the .Sales Target. column. - Use a conditional format formula: =A1<B1. Apply it to the entire column you want shaded, and Excel will evaluate the seperately for each cell. The cell references in the format formula are relative to the current cell in the selected range. The current cell is the cell in the range that is not highlighted (but is surrounded by a selection border), and can be moved around the four corners of the range with Control+. (period).
  • When working with tables, we have also made it easy to format the entire row based on the results of a condition. - Relative formulas can be made to do this: select an entire range, and define a conditional formula using absolute column addresses (ie: =$a1). Excel evaluates the format formula for each cell in the range, and since the column addresses are absolute, each cell in a row will pull from the came columns. Therefore, each cell in a row will share the same conditional format, which is what we want.

Based on this, you don't have to wait for Excel 12 to get a lot of these features, you just have to wait for Excel 12 if you want Excel to do it for you automatically. My suggestion would be to learn how to use conditional formatting formulas, but I tend to be "here's how to fish" kind of guy more than a "here's a fish" kind of guy.

June 30, 2005

For a few years, I used this graphic as the front matter for my website:

michael.schaeffer

This, the logo for my website, is basically just antialiased text rendered into a bitmap. At the time, it seemed like a good idea to render the text as a bitmap because I didn't trust the browser to render it for me. Bad idea.

As it turns out, Internet Explorer rescales bitmaps on high resolution displays. This is a somewhat misguided attempt to make keep bitmap sizing consistent. Bitmaps aren't rendered at 1/1 zoom, they are rendered at screen_dpi/96dpi. On non-96dpi screens, that results in ugly scaling. While scaling can be disabled, that's not the ideal solution. The ideal solution is to do as much of the rendering as possible in the browser: which should know more about the client's display than the server. Therefore, my logo is now CSS formatted plain text. That means it looks the right size on more screens, anti-aliases appropriately, uses ClearType if it's available. The next step is going to be to switch from pixel sizes to 'real' sizes.

June 23, 2005

Oddly enough, the search term that brings the most visitors to my little website is "Texaco". I suspect most of those people go away totally unsatisfied, but there is a decent story behind the connection:

About ten years ago, a good friend of mine went to work in Texaco's IT Shop as a summer intern. One of his job responsibilities was to develop an intranet website. I forget the details, but somewhere along the way he decided he wanted to put a fancy banner picture atop the page. At the time, we were both interested in ray tracing, so we decided to throw together a raytraced version of the Texaco Star logo.

Using our copious free time, we found an online copy of the Texaco logo, took measurements of the star and rendered it as a white solid set against a metallic red hemisphere. We even went to the trouble of animating the star so it rotates, generating a bunch of frames and using a GIF tool to put together an animated GIF. The final result was a nicely animated Texaco logo with an "attractive" (This is by 1995 intranet standards, remember) banner to the side. Since then, I've dragged the model out, re-rendered it at higher resolution, and stuck it in a little Raytracing Gallery I have set up.

For some reason, that picture brings more visitors to this site than anything else. If you happen across this site and actually use the image for something you owe its presence to a ten year old accident of fate.

June 23, 2005

I thought these acronyms were dead 15 years ago, when SuperVGA and the 8514/A started to replace the VGA. here's a good history and glossary of the terms, but what's wrong with "2.3MP, 16:10" instead of WUXGA? So much simpler, and it also provides a decent way to compare screen resolutions with digital camera resolutions.

June 3, 2005

This post spoke to the use of ClearType to improve text rendering in vCalc. This "after" screenshot was taken from a laptop running ClearType:

Since ClearType depends on the unique properties of LCD's, it won't look as good on a CRT. (I still think it looks better than normal, though).

May 27, 2005

I just found about it, but I already think it might end up in vCalc. Anti Grain Geometry is a open source 2D rendering library with a very liberal license. The feature set looks pretty comprehesive: it supports anti-aliasing, affine transforms, sub-pixel resolution, and alpha blending. Even better, it's designed as a lightweight set of C++ classes, so it shouldn't bloat or slow down vCalc too much. About the only hole is that it doesn't have any kind of built in text rendering; However, even there there are are detailed instructions for using the Windows True Type renderer to generate glpyhs.

All I need now is time...

May 17, 2005

This is well documented on MSDN, but it's still pretty cool.

I've never been happy with the text quality of the vCalc display: it's jagged and at a font size that doesn't rasterize well on the displays I have access to. Well, as it turns out, this is relatively easy to fix. The LOGFONT structure that GDI uses to select fonts has a field, lfQuality, that is used to select the quality of the text rendering. Back in olden days, this field was used to do things like disallow scaling of bitmap fonts (if you don't know what that is, be thankful: it was awful). These days, it's used to turn on Antialiasing and Cleartype (on winXP). Thus, this one line of code:...

lf.lfQuality = CLEARTYPE_QUALITY;

...transformed this...

...into this.

There's also a setting for anti-aliasing:

lf.lfQuality = ANTIALIAS_QUALITY;

Anti-aliasing (in Windows) dates back to the Windows 95 Plus pack, so this setting should be much more widely supported. However, it's also much less powerful: it doesn't do any of the sub-pixel stuff and it is enabled far less often. In my experimentation, non-bold fonts had to be pretty big before anti-aliasing was used at all.

The other caveat is that this doesn't automatically buy you decent formatting of the text you display. That is, if you're still computing text positioning on per-pixel increments, you'll still get mediocre layout. vCalc does this, but it also has very minimal text layout requirements for now.

March 4, 2005

This is cool. What it is is a web-based color picker that automatically gives you a couple different kinds of complementary colors.

Older Articles...