Blur Filter performance: PhotoDemon vs GIMP vs Paint.NET

(Note before I begin: the PhotoDemon 6.0 beta should be live by the end of this week. Sorry it took so long to prepare!)

See what kind of fun charts we get to discuss?  And here I thought the days of 17-minute photo editing actions died with the Pentium III...
See what kind of fun charts we get to discuss? And here I thought the days of 17-minute photo editing actions died with the Pentium III…

The latest nightly build of PhotoDemon (download it here) includes a bunch of new and improved blur filters. Blur filters are among the most computationally demanding filters in a photo editor, because for each pixel in an image, a bunch of other pixels must also be examined in order to calculate the blur. (Blurs generally work by averaging together groups of pixels. Motion blur averages pixels in a line, radial blur averages pixels in an arc, and normal blur averages pixels in a box or circle shape.)

As a simple example, consider a basic blur with a 200 pixel radius, applied to a 10 megapixel digital photo. For each pixel in the photo (all ten million of them), an area of 200 pixels in each direction must be averaged together. Using a simple box blur, that means a box of 200 pixels left, right, up and down must be tallied (for a net area of 400 * 400, or 160,000 pixel comparisons) in order to calculate the blur. Thus, such an algorithm would require:

10,000,000 pixels * 160,000 calculations per pixel = 1.6 trillion total calculations

Even on a modern processor, that’s an enormous undertaking. Fortunately, mathematicians and coders have developed many clever ways to optimize blur functions. Many of these optimizations appear in the newest PhotoDemon build, so I thought it would be fun to speed-test four of PhotoDemon’s blur tools against two other free photo editors: GIMP and Paint.NET. The results were surprising enough that I thought them worth sharing.

A brief overview of each photo editor:

  • PhotoDemon: open-source, written in VB6, nightly build 893 (6.0 beta)
  • GIMP: open-source, written primarily in C, v2.8.6
  • Paint.NET: closed-source, written primarily in C# (and the .Net framework, per the name), v3.5.11

As benchmarking goes, this was very informal. PhotoDemon reports timing automatically in nightly builds, but for GIMP and Paint.NET I had to resort to using a stopwatch. Normally this is a terrible idea, but the algorithms involved take a very long time to run, so a stopwatch was sufficient for broad timing. (10ths of a second don’t matter much when an algorithm takes twenty minutes to finish…)

All tests were done on Windows 7 (64-bit), on my Core i5 650 (3.2ghz) desktop PC with 8gb of RAM. My PC was middle-of-the-road when I bought it back in 2010, so I’d consider reasonably representative of an “average” PC. All the tools in question appear to be heavily CPU-bound anyway, so it’s doubtful newer processors or more cores would make a meaningful difference.

The test photo I used was a 10 megapixel photo, 3872×2592 specifically, in JPEG format:

10 megapixel test photo

With the exception of some very long timings (10+ minutes), all timings were checked twice to make sure results were representative. Very long ones were only checked once due to the wait involved, though I did initiate a second attempt just to make sure my PC wasn’t acting up. (It wasn’t.)

Here are the timing results for four separate blur types, with some notes on my implementation, and what I know or can potentially infer about GIMP and/or Paint.NET’s implementations.

(Due to the large size of the images involved, I saw no reason to upload the output images of each test. Anyone interested can easily reproduce this test on their own PC with images of their choosing.)

Gaussian Blur

Two notes - PhotoDemon used the "good" quality setting, which is a Gaussian estimation using a modified 3x box blur, and GIMP used the IIR method.
Two notes – PhotoDemon used the “good” quality setting, which is a Gaussian estimation using a modified 3x box blur, and GIMP used the IIR method.

Gaussian Blur provides an excellent starting point. Gaussian blur works by averaging a square chunk of pixels, and giving pixels close to the center more weight than pixels far away. It is the most common type of blur tool in photo editing software, probably because its results are aesthetically pleasing, and it is an easy blur function to optimize.

Instead of a naive approach, which would involve the 1.6 trillion calculations mentioned above, most photo editors implement Gaussian Blur using a separable implementation, which cuts the calculations to a much more pleasant 8 billion calculations. Unfortunately, 8 billion calculations is still a lot. (PhotoDemon’s “best quality” option on its Gaussian tool applies a pure Gaussian using separable kernels. On large images, it’s slow. Very slow.)

An even faster approach takes advantage of a neat mathematical relationship between box filters and Gaussian filters: if you keep applying a box filter to a set of data, the result will eventually approach a Gaussian distribution. (Excellent charts available here, courtesy of Nghia Ho.) The Central Limit Theorem shows that repeating a box blur three times results in a function that’s ~97% identical to a true Gaussian.

PhotoDemon uses this as the basis for its three quality settings for Gaussian blur (good, better, and best). Good is a 3x box blur approximation, Better is a 5x, and Best is a true Gaussian. For the chart above, I used the “good” setting because it is by far the fastest. (Note that there’s a bit more to it than just repeating a box blur – how you calculate the box blur size matters; I use a variation of the W3 recommendation available here.)

Take-home message: GIMP’s IIR implementation is excellent – very fast, and it produces a true Gaussian, no estimations. PhotoDemon is surprisingly competitive for a single-threaded VB6 app. Paint.NET’s Gaussian is quite poor both in quality and final result. Its resulting blur is muddier than a true Gaussian, and much slower than you’d expect for a box-blur approximation… so I honestly have no idea how they’ve implemented it.

Motion Blur

PhotoDemon used "Quality" mode instead of "Speed", meaning bilinear interpolation was applied to the rotated image.  No extra options are available for this tool in GIMP or Paint.NET.
PhotoDemon used “Quality” mode instead of “Speed”, meaning bilinear interpolation was applied to the rotated image. Also, “blur symmetrically” was checked. No extra options are available for this tool in GIMP or Paint.NET.

Motion blur is a bit more problematic than Gaussian blur, because it doesn’t work in a square pattern. A naive approach would have you use something like Bresenham’s algorithm on each pixel, tracing a line at the specified angle and averaging interpolated values as you go.

A much better approach is to simply rotate the image by the requested angle, apply a (very fast) horizontal blur, then rotate the image back into place. If you use a fast rotation algorithm (like the famous 3-shear technique), this can make motion blur very quick.

My PhotoDemon implementation does not use the fast 3-shear technique; it uses a naive, geometric rotation (reverse-mapped) with bilinear interpolation. I expected this to make it quite a bit slower than comparable tools in GIMP and Paint.NET, but I was surprised to discover that both software packages are… well, pretty damn terrible.

Based on a brief perusal of GIMP’s source code, they appear to use the naive Bresenham approach, which explains why it’s so slow.

Once again, Paint.NET’s execution time makes no sense to me. For a software package that claims: “extensive work has gone into making Paint.NET the fastest image editor available“, methinks they need a bit more “extensive work” on this particular tool…

Radial Blur

As before, PhotoDemon uses the "quality" setting for bilinear interpolation.  Paint.NET was applied at quality setting 2 out of 5, the default setting.  (This results in a noticeably lower-quality image than PhotoDemon or GIMP.)  GIMP does not provide any additional options for this tool.
As before, PhotoDemon uses the “quality” setting for bilinear interpolation. Paint.NET was applied at quality setting 2 out of 5, the default setting. GIMP does not provide any additional options for this tool.

And so we move to Radial Blur, where we find a surprising role reversal: Paint.NET gives a much better showing here, while GIMP turns in the worst performance yet. Again, a brief look at GIMP’s source code for this function shows a questionable nested-loop approach to the problem. Tracing an arc-like path for each pixel is a bad idea, and while bilinear interpolation is used to improve the output quality – same as PhotoDemon – the time required makes this tool pretty much unusable.

PhotoDemon’s implementation is nothing particularly special, which makes its relative performance so surprising. I use a well-known trick where I convert the image to polar coordinates, apply a horizontal blur, then convert the image back to Cartesian coordinates. A small amount of image quality is lost by the two coordinate conversions, but because we are blurring the image anyway, this doesn’t matter much. That said, for small angles (< 5 degrees), both GIMP and Paint.NET produce better-looking output. At larger radii, however, PhotoDemon's is much better. Both GIMP and Paint.NET produce Moire patterns, presumably from sampling at discrete intervals, while PhotoDemon’s output is clean and smooth. This can probably be fixed in Paint.NET by using a higher quality setting, but quality setting 2/5 was already slow enough!

The top-left corner of the image after PhotoDemon's radial blur.  Buttery smooth, and accurate edge handling.
The top-left corner of the image after PhotoDemon’s radial blur. Buttery smooth, and accurate edge handling.
Same corner, but from Paint.NET's radial blur.  Nasty Moire patterns, and problematic handling in the corner - from an algorithm that took 4x longer to run.
Same corner, but from Paint.NET’s radial blur. Nasty Moire patterns, and problematic handling in the corner – from an algorithm that took 4x longer to run.

Zoom Blur

No, that huge green bar is not an error.  GIMP took a whopping 17 minutes to render a 200px zoom blur.  PhotoDemon's "traditional" mode was used to provide comparable output.  Paint.NET does not offer any specialized options for this tool.
No, that huge green bar is not an error. GIMP took a whopping 17 minutes to render a 200px zoom blur. PhotoDemon’s “traditional” mode was used to provide comparable output. Paint.NET does not offer any specialized options for this tool.

Last up is Zoom Blur, and we have a surprising winner! Paint.NET’s zoom blur implementation is excellent – great quality, very fast, and overall a huge improvement from their other blur tools. I have no idea why Zoom Blur is significantly faster than their Gaussian Blur implementation at a comparable pixel size, so I can only assume that some kind of specialized optimizations have been added. Nice work, Paint.NET team!

GIMP… I don’t even know what to say. It’s possible that I triggered some sort of problem with GIMP’s tile-based processing system, because there is no good way to explain a 17-minute processing time for such a straightforward function. Even a naive implementation shouldn’t take anywhere near that long. Their implementation has loops nested five-deep (dear god), and while bilinear interpolation is used to improve output, that algorithm is so poorly written that I frankly think they should consider removing it completely. Even at very low distances, rendering takes forever. The original copyright date on the source file is 1997, so perhaps someone familiar with GIMP’s internals should give this one a second look.

PhotoDemon uses the same trick here as with radial blur. The image is converted to polar coordinates (with swapped x and y values compared to the radial blur conversion), a horizontal blur is applied, then the image is converted back. Again, there is quality loss at low values, and both Paint.NET and GIMP provide better-quality output at very small radii. To mitigate this, I provide a second style on that dialog, which uses an iterative image-sized alpha blend to generate a blur. One of the neat things about that approach is that the image can be zoomed-out as well as zoomed-in.

I doubt there is a legitimate use for zoom-blur-outward like this, but it wasn't any extra work to implement.  :)
I doubt there is a legitimate use for zoom-blur-outward like this, but it wasn’t any extra work to implement. :)

Conclusions

Blur algorithm performance is hugely variable in both GIMP and Paint.NET. I’ll admit – I find it a bit amusing that my little PhotoDemon project, written with a 15-year-old programming language and compiler, outperforms them so handily in multiple areas, despite my implementations being generally lazy, single-threaded, and heavily CPU-bound. I also call “bullshit” on Paint.NET’s claim about “extensive work going into making Paint.NET the fastest image editor available.” I think the Paint.NET team does great work, and their software is a wonderful improvement over many free and paid photo editors, but its performance is greatly lacking in a number of areas.

Then there is GIMP. While I am very grateful for their software, and have learned to love its many quirks, there’s no denying that whole swaths of its source code are in desperate need of a revamp. I imagine there is no point revisiting items like blur until they complete their migration to GEGL – perhaps then we will see big improvements in the performance of these various blur functions.

If there’s a take-home message to all this, it’s that algorithms will always be more important than programming languages. A well-written algorithm in a “slow” language will often outperform a poorly written algorithm in a “fast” language. VB6 may be forgotten and nearly dead, but I’m happy to see it staying competitive with the titans of the “free photo editor” world. :)

If you read the article all the way to here, I hope you’ll give PhotoDemon a look:

http://www.tannerhelland.com/photodemon/#download

For a free, open-source photo editor, it has a lot of nice features, and I can empirically state that it outperforms GIMP and Paint.NET in at least a few areas! (The current nightly build is pretty much how the next stable release (6.0) will look, minus a few minor bugfixes still to complete.)

How to compile zLib 1.2.8 (WINAPI / WAPI / STDCALL version)

This is not a full-blown article – just a quick HOWTO for people who require the latest version of zLib and want to use it from a language (like classic VB) that requires a standard WinAPI interface.

By default, zLib uses C calling conventions (CDECL). Gilles Vollant has helpfully provided an STDCALL version of zLib in the past, but his site only provides version 1.2.5, which dates back to January 2012. zLib is currently on version 1.2.8.

Gilles has contributed his WAPI fixes to the core zLib distribution so that anyone can compile it themselves. To do this, you will need to download:

Once both of those are downloaded (and updated, as VS 2012 will require you to install several service packs), follow these steps to compile zLib yourself:

  1. Extract the entire zLib file and navigate to the /contrib/masmx86 folder. Open the “bld_ml32.bat” file in a text editor.
  2. Add the “/safeseh” switch to both lines in that file (e.g. “ml /safeseh /coff /Zi /c /Flmatch686.lst match686.asm”). Then save and exit.
  3. Navigate to the /contrib/vstudio/vc11/ folder. Open the zlibvc.sln file in your newly installed Visual Studio 2012 Express.
  4. In the Solution Explorer (top-right by default), right-click “zlibstat” then select “Properties” at the bottom.
  5. Go to Configuration Properties -> C/C++ -> Preprocessor, and in the Preprocessor Definitions line remove “ZLIB_WINAPI;” (don’t forget to remove the trailing semicolon).
  6. Now, we need to fix a recently introduced problem that relies on Win8 functionality. In the Solution Explorer, navigate to zlibvc -> iowin32.c. Double-click to open the file.
  7. Find the line of text that reads “#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)”. Change this line to “#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY_DESKTOP_APP, WINAPI_PARTITION_APP)”. (Thanks to this link for this fix.)
  8. zLib uses a Version number declaration that can cause the build process to fail. To fix this, go back to the Solution Explorer, then navigate to zlibvc -> zlibvc.def. Double-click to open.
  9. Change the line that reads “VERSION 1.2.8” to read “VERSION 1.28”.
  10. Finally, go to the Build -> Configuration Manager menu and change the Active Solution Configuration to “Release”.
  11. Exit that window and press F7 (or click the Build -> Build Solution menu). The project should successfully build.
  12. You can find your newly compiled zlibwapi.dll file in the /contrib/vstudio/vc11/x86/ZlibDllRelease/ folder.

Where does Microsoft make money? (Updated 2013)

(Past reports here: 2012, 2011, 2010, 2009)

Introduction

As in past years, all information in this report is taken from Microsoft’s publicly available 2013 10-K filing. Numbers may vary from past reports. When Microsoft moves products between revenue categories, they retroactively adjust the totals for past years so that year-to-year comparisons are accurate. This article uses 2011 and 2012 values as calculated in the 2013 report. All values are in USD.

If you’ve read my past reports, feel free to skip down to the charts. If this is your first time here, let me provide a quick explanation of how Microsoft breaks down its earnings.

Microsoft 2013 earnings tl;dr (“too long, didn’t read”)

  • Microsoft remained highly profitable in 2013, with solid year-over-year growth in both revenue and operating income.
  • The Business (Office) division brings in significantly more money than the Windows division (+30% revenue, +70% profit). In fact, nearly half of Microsoft’s 2013 profits came from the Business division alone.
  • For the first time ever (to my knowledge), the Windows division was actually 3rd in revenue in 2013, behind both Business and Server/Tools. If trends from the past four years continue in 2014, Server and Tools will pass Windows in not just revenue, but profitability as well.
  • Regardless of division, the vast majority of Microsoft’s profits come from business and OEM sales. Consumer-centric divisions (including XBox, Windows Phone, Bing) are largely irrelevant from a profit standpoint.
  • Just for fun: in 2012, Apple pulled in double the revenue of Microsoft ($156 billion USD and $74 billion, respectively). Source 1, Source 2.

Overview

Microsoft is unique among tech companies for reporting detailed information by product line. Their competitors do not provide such a detailed breakdown; Apple, most notably, is organized around “functional” divisions rather than “product” divisions, making direct financial comparisons between Apple product lines and Microsoft product lines difficult.

This year, Microsoft announced a company-wide reorganization plan that would bring them closer to Apple’s structure. Many (myself included) have doubts about this resulting in meaningful changes to Microsoft’s overall structure and performance, but there is one area the reorganization is almost certain to impact: financial reporting. Sadly, this means that 2013 may be the last year I am able to provide detailed earnings charts by product division.

There are many theoretical benefits to organizing a company by “function” instead of “products.” One benefit is reduced infighting between product groups, a known problem for Microsoft. Another benefit is the ability to hide losses due to underperforming products. Microsoft had its share of those in the past year, most notably its billion-dollar loss on the Surface RT line of tablets, the impact of which can be seen in the charts below.

Microsoft Total Revenue and Operating Income (June 2012 – June 2013)

Total Revenue: $77,849,000,000
Operating Income: $26,764,000,000

Long story short: for all their failings, Microsoft remains hugely profitable.
Long story short: despite some big missteps in 2013, Microsoft remains very profitable.

Total Revenue is the total amount of money Microsoft takes in from normal business operations.

Operating Income is calculated as “Operating Revenue – Operating Expenses”. In other words, Operating Income is the profit made from normal business operations. (A more detailed definition is available from Investopedia: “Operating income would not include items such as investments in other firms, taxes or interest expenses. In addition, nonrecurring items such as cash paid for a lawsuit settlement are often not included. Operating income is required to calculate operating margin, which describes a company’s operating efficiency.”)

Operating Income is particularly important when looking at a company like Microsoft. Certain Microsoft divisions take in a great deal of money, but they also require much higher costs to operate. Thus it is relevant to look at not just how much money a certain division brings in, but at how efficiently that division generates its revenue.

Microsoft Revenue and Operating Income by Division (June 2012 – 2013)

Microsoft products (and earnings) are divided into five divisions: Windows, Microsoft Business, Server and Tools, Entertainment and Devices, and Online Services. The types of products and services provided by each segment are as follows.

(Note: these divisions are pretty much identical to 2012, with the exception of Microsoft’s $1.2 billion purchase of Yammer and its corresponding addition to the Microsoft Business division.)

Here are the 2012-2013 revenue and operating income values for each division, in USD. Note that the number in parentheses is the percentage change between 2012 and 2013.

Windows (including Surface tablets and other hardware)
Revenue: $19,239,000,000 (+5%)
Operating Income: $9,504,000,000 (-18%)

Business (Office, Exchange, SharePoint)
Revenue: $24,724,000,000 (+3%)
Operating income: $16,194,000,000 (+2%)

Server and Tools (Windows Server, Microsoft SQL, Visual Studio)
Revenue: $20,281,000,000 (+9%)
Operating Income: $8,164,000,000 (+13%)

Entertainment and Devices (XBox 360/LIVE, Windows Phone)
Revenue: $10,165,000,000 (+6%)
Operating income: $848,000,000 (+120%)

Online Services (Bing, MSN, Hotmail)
Revenue: $3,201,000,000 (+12%)
Operating income: $-1,281,000,000 (*)

(* – Microsoft had an artificially huge loss in the Online Services division in 2012, due to a one-time goodwill impairment charge of $6.2 billion. This makes year-to-year comparisons meaningless.)


Microsoft Total Revenue – 2013

MS_2013_revbydivision_USD
Microsoft total revenue in 2013, in USD.

 

MS_2013_revbydivision_percent
Same chart as above, but with percentages.

Microsoft Operating Income – 2013

Microsoft operating income, by division, for 2013. (Amounts in millions USD.) Note that Online Services represents a $1.2 billion dollar LOSS.
Microsoft operating income, by division, for 2013. (Amounts in millions USD.) Note that Online Services represents a $1.2 billion dollar LOSS.

Year-over-year comparisons (2010-2013)

Microsoft revenue by division for the years 2010-2013. Overall revenue continues to trend upward, despite flat Windows sales.  Note that as of 2013, both Office and Server/Tools brought in more money than Windows.
Microsoft revenue by division for the years 2010-2013. Overall revenue continues to trend upward, despite flat Windows sales. Note that as of 2013, both Office and Server/Tools brought in more money than Windows.

 

Microsoft operating income by division for the years 2010-2013. Unlike revenue, operating income varies dramatically from year to year. Microsoft Business has now dominated profits for three straight years, and if trends continue, Server and Tools will surpass Windows in profitability next year.  Note also how irrelevant XBox and Windows Phone (E&D) are from a profit standpoint.
Microsoft operating income by division for the years 2010-2013. Microsoft Business has now dominated profits for three straight years, and if trends continue, Server and Tools will surpass Windows in profitability next year. Note also how irrelevant XBox and Windows Phone (E&D) are from a profit standpoint.

Hooking modern Windows common dialogs: some notes

Background: common dialog hooking is used to append your own controls to a Windows common dialog box.

A good friend recently sent me a number of resources related to hooking common dialog controls. I’ve been interested in common dialog hooking for PhotoDemon, as it would allow me to add support for image previewing right in the dialog itself. This isn’t as necessary in modern versions of Windows (7 in particular includes a number of GDI+ improvements, making Explorer very robust with standard formats), but it can be helpful for unsupported formats like RAW photographs.

Unfortunately, several days of research have shown that it is not possible to hook a Vista or Windows 7 style dialog and maintain the modern layout. Let me explain with pictures:

This is the standard common dialog control in Windows Vista and 7 (and presumably 8 as well, though I haven't verified this myself).  The biggest improvements over past common dialogs include breadcrumb navigation at the top, a dedicated refresh button, and a persistent search bar.
This is the standard common dialog control in Windows Vista and 7 (and presumably 8 as well, though I haven’t verified this myself). The biggest improvements over past common dialogs include a dedicated left-hand file tree, breadcrumb navigation at the top, and a persistent search bar.

The common dialog above comes directly from PhotoDemon’s current common dialog implementation. This is the native common dialog control on Vista and 7. I very much like it. As a comparison, here is the same dialog in Windows XP:

Same folder as the previous image.  The XP common dialog provides no breadcrumb nav, folder tree, dedicated refresh, or search bar.  Note also how many TIFF formats do not display correctly - including XP not recognizing the MINISWHITE flag on the CCITT TIFF files.  Kinda interesting.
Same folder and images as the previous image. There is no breadcrumb nav, dedicated refresh, or search bar. Note also how many TIFF formats do not display correctly – including XP not recognizing the MINISWHITE flag on the CCITT TIFF files. Kinda interesting.

I strongly prefer the Vista/7-style dialog, particularly the breadcrumb nav and the persistent folder tree on the left.

Unfortunately, it is impossible to hook the Vista/7 dialog and maintain the native Vista/7 appearance. If you attempt to hook it, Windows will ALWAYS drop back to a previous generation common dialog. Here are some images to demonstrate, using a basic image preview hook:

This is what happens when you attempt to hook a dialog, and all you provide is the OFN_ENABLEHOOK flag.  Not pretty (and the hook doesn't even work right).
This is what happens when you attempt to hook a dialog, and all you provide is the OFN_ENABLEHOOK flag. Not pretty (and the hook doesn’t even work correctly).
Here is the same dialog, but with the OFN_EXPLORER flag set.  Note that hooking now works properly, but the common dialog itself has been reduced to XP style - the left-hand folder tree is gone, and the top bar has no breadcrumbs or search.
Here is the same dialog, but with the OFN_EXPLORER flag set. Note that hooking now works properly, but the common dialog itself has been reduced to XP style – the left-hand folder tree is gone, and the top bar has no breadcrumbs or search.

Note that the image above uses an older version of the OPENFILENAME struct, namely (this is its declaration in VB):

Private Type OPENFILENAME
    lStructSize       As Long
    hwndOwner         As Long
    hInstance         As Long
    lpstrFilter       As String
    lpstrCustomFilter As String
    nMaxCustFilter    As Long
    nFilterIndex      As Long
    lpstrFile         As String
    nMaxFile          As Long
    lpstrFileTitle    As String
    nMaxFileTitle     As Long
    lpstrInitialDir   As String
    lpstrTitle        As String
    Flags             As Long
    nFileOffset       As Integer
    nFileExtension    As Integer
    lpstrDefExt       As String
    lCustData         As Long
    lpfnHook          As Long
    lpTemplateName    As String
End Type

If you modify the struct to its newest version (as described here), you can slightly improve the dialog to look like this:

The newest version of the OPENFILENAME struct enables the places bar on the left.  I don't find this particularly useful - certainly not as useful as a folder pane - but perhaps some might find it preferable.
The newest version of the OPENFILENAME struct enables the places bar on the left. I don’t find this particularly useful – certainly not as useful as a folder pane – but perhaps some might find it preferable.

That is the best you can get if you want to hook a common dialog in Vista or 7.

Reasons for this have been speculated on by more qualified individuals than I. Over at stackoverflow, David H explains:

The reason for this is that MS completely re-organised the file dialogs for Vista. Hooks are used to extend a file dialog by supplying a resource file. This gives the customiser too much power. They can all too easily modify standard elements of the dialog and indeed many apps did so. The reorganisation of the dialogs would have broken many apps that used hooks. Those would have tried to manipulate elements of the dialog that were not there, or were implemented differently. Legacy versions of the dialogs remain for such apps to “get their hooks into”.

You are correct that it is impossible to get the new look when you use a hook. Instead you need to use the IFileDialogCustomize interface to customise the dialog. This is less powerful but does result in appearance and behaviour that is more consistent with the standard part of the dialog.

(More information is available here for those who are interested.)

Unfortunately, I am not aware of any way to access the iFileDialogCustomize interface in classic VB. If someone knows how, I’d love to hear it.

The take home message of all this is – if you work in classic VB and you want to hook a common dialog, you need to be content with an XP-style dialog. There is currently no way to maintain a Vista/7 style dialog while hooking.

For this reason, I’m going to stick with the stock common dialog control in PhotoDemon. I may look at a dedicated “browse” window in the future, which would allow for full image previewing, but I’m afraid such a feature is not on the roadmap for the next few versions.

All hooking-related screenshots were created using Carles PV’s iBMP project, which made it very easy to modify various hooking parameters and test the output. Thanks, Carles!

Announcing PhotoDemon 5.0 – Everything is Faster, Everything is Better

Summary

PhotoDemon v5.0 is now available. It’s the biggest update PhotoDemon has seen in years, and it’s awesome. Download it here.

PhotoDemon 5.0 boasts a ton of improvements – both on the surface and under the hood.

New Feature: All-New Image Subsystem

In version 5.0, the way PhotoDemon stores and processes image data has been rewritten from scratch. What does this mean for you?

  • Filters, effects, and all tools are faster than version 4.4.
  • The software uses roughly half the RAM of previous versions.
  • No more upper limit on image sizes. Huge photos (30+ megapixel) should work just fine on any modern PC. The only limiting factor is the amount of RAM (actual and virtual) available on your system.
  • Much faster batch conversions. As an example of how much better version 5.0 is: I ran two identical batch conversions of 138 wedding photos (10 megapixels each, 3872×2592 pixels). The batch conversion was simple – load each image, then save it in another folder at a different JPEG quality. PhotoDemon 4.4 performed the conversion in 2 minutes 21 seconds. PhotoDemon 5.0 does it in 1 minute 11 seconds.
  • Much better OSX and Linux compatibility via Wine. (Wine v1.4 or later is required.)

This sole feature was the largest update PhotoDemon has seen in the past five years. As a teaser, the new subsystem is also compatible with selections and layers, which may make an appearance in a future update…

New Feature: Alpha-Channel (Transparency) Support

For the first time in the history of the program, PhotoDemon now provides proper transparency support. When images with an alpha-channel are loaded, PhotoDemon will automatically maintain the transparency data for the life of the image. When the image is saved to file, the alpha-channel is added back in, allowing you to do any amount of edits to images without harming the underlying alpha data.

Transformations like resizing and rotating also preserve the alpha channel. (Again, this was a prerequisite to features like layers… see a pattern here?)

New Feature: Redesigned Interface

Every menu item in PhotoDemon now has a descriptive icon, and menus have been reorganized according to improved design rules. No menu is more than two layers deep, and new accelerators (hotkeys) have been added to popular features.

The redesigned Color menu

The left-hand bar has been updated once again. Per feedback from users, a dedicated Close and Save As button has been added, along with descriptive text for each button. Tool-tips have also been added to each button. (Thanks to Robert Rayment for the suggestion!) Finally, the zoom box has been rebuilt with a new, more useful set of zoom values.

New left-hand bar in 5.0, including descriptive tool-tips.

All preview boxes have been enlarged on tool, filter, and effect windows. Text has also been enlarged to improve readability. PhotoDemon was originally designed to run on 800×600 resolutions (that was a concern in 2001!) but there’s no need for it to remain so compact in 2012.

The old and new edge detection tools
The old and new Custom Filter tools

Finally, a new View menu has been added to provide compatibility with other popular photo editors. The new menu is a great place to discover all the useful hotkeys (also called “accelerators”) for popular zoom functions. The key listed on the right-hand side of a menu item can be used as a shortcut to that menu – so pressing the “+” key will zoom in, the “-” key will zoom out, and the “0” key will instantly fit the entire image on the screen.

The new View menu

New Feature: All-New Image Load/Save Engine

PhotoDemon 5.0 uses a completely new system for getting images into – and out of – the program. As you may know, the program relies on an outside library called FreeImage for supporting non-standard image formats like Photoshop files (PSD), Macintosh PICT files (PICT), DirectDraw surfaces (DDS), and more.

FreeImage is an excellent tool, but its implementation in past versions of PhotoDemon was very rudimentary. PhotoDemon relied on FreeImage to do its own image file type detection, configure each image type properly, and prepare it for use within the program. While it was pretty good at guessing these parameters, it was not foolproof, and odd color-depths, transparencies, and mismatched file extensions could result in failed image loads or even program crashes.

So for version 5.0, the FreeImage interface was rewritten from the ground up. When images are loaded, a fallback system is used to identify the file format – first the file header is compared against a database of known filetypes. That works for 95+% of files. If for some reason a header cannot be found (which is the case with some formats, including outliers like CUT, MNG, PCD, TGA and WBMP), the image’s file extension is then analyzed. If that fails, PhotoDemon will attempt to blindly load bitmap data and hope for the best. And, if even that fails, PhotoDemon will give the image one final try by passing control off to the Windows’ GDI+ system and seeing if it can decipher the file.

This should make PhotoDemon as robust as possible when loading images. (Thanks to Herman Liu for much testing and help with the new image import implementation!) The full list of file formats supported by PhotoDemon now includes:

Importing:

  • BMP – Windows Bitmap
  • DDS – DirectDraw Surface
  • GIF – Compuserve
  • ICO – Windows Icon
  • IFF – Amiga Interchange Format
  • JNG – JPEG Network Graphics
  • JPG/JPEG – Joint Photographic Experts Group
  • KOA/KOALA – Commodore 64
  • LBM – Deluxe Paint
  • MNG – Multiple Network Graphics
  • PBM – Portable Bitmap
  • PCD – Kodak PhotoCD
  • PCX – Zsoft Paintbrush (uncompressed only)
  • PDI – PhotoDemon Image (the program’s native format)
  • PGM – Portable Greymap
  • PIC/PICT – Macintosh Picture
  • PNG – Portable Network Graphic
  • PPM – Portable Pixmap
  • PSD – Adobe Photoshop
  • RAS – Sun Raster File
  • SGI/RGB/BW – Silicon Graphics Image
  • TGA – Truevision Targa
  • TIF/TIFF – Tagged Image File Format
  • WBMP – Wireless Bitmap

Exporting:

  • BMP – Windows Bitmap
  • GIF – Graphics Interchange Format
  • JPG – Joint Photographic Experts Group
  • PDI – PhotoDemon Image (the program’s native format)
  • PNG – Portable Network Graphic
  • PPM – Portable Pixel Map
  • TGA – Truevision Targa
  • TIFF – Tagged Image File Format

New Feature: Color Temperature Tool

A full discussion of color temperature and how it works is available at this Wikipedia article, but a simple description is: color temperature allows you to retroactively adjust the lighting of a photograph. It’s a powerful way to change the mood of a photo, or to adjust lighting to reflect how you remember a scene – versus what the camera actually caught.

The all-new Color Temperature tool. To my knowledge, no other free photo editor provides a tool like this.

I’m quite proud of this tool, in part because it took a ridiculous amount of work to build. Other free photo editors like GIMP and Paint.NET lack anything like this, so short of Photoshop, PhotoDemon is one of the only software programs to provide such a feature.

The image below – a promotional poster for the HBO series True Blood – nicely demonstrates the potential of color temperature adjustments. On the left is the original shot; on the right, a color temperature adjustment using PhotoDemon. In one click, a nighttime scene can been recast in daylight.

Color temperature adjustment in action.

New Feature: Black and White (1-bit) Conversion

PhotoDemon already possesses a powerful grayscale engine, with more conversion options than any other tool on the market. But what if you want to literally convert an image to black and white – as in just black and just white?

Now you can, thanks to a revamped black-and-white tool.

The new black-and-white tool, rewritten from scratch for 5.0.

The new tool operates hand-in-hand with a flexible, powerful dithering engine. The new engine design allows for any combination of dithering and threshold, and if you’d like, you can also have PhotoDemon estimate an ideal threshold value for a given image. (An ideal threshold is one that leads to an image that’s roughly 50% black and 50% white.)

A comprehensive assortment of dithering algorithms is provided, including: Bayer 4×4 and 8×8, False (fast) Floyd-Steinberg, Genuine Floyd-Steinberg, Jarvis/Judice/Ninke, Stucki, Burkes, Sierra-3, Two-Row Sierra, Sierra Lite, and my personal favorite – Bill Atkinson’s classic Macintosh algorithm, which featured prominently in the original Apple Macintosh. Images treated with this algorithm evoke a certain nostalgia for anyone old enough to remember that era of computing.

Atkinson dithering, as applied to a screen capture from a Warehouse 13 episode.

New Feature: Tile Tool

Have you ever needed to tile an image? There are a lot of ways to do it. Most involve copying-and-pasting an image over and over again, then manually arranging those copies into a grid.

I hate tedious tasks like that. So PhotoDemon has a new tool that makes tiling a trivial operation.

The new Tile tool.

You can tile according to three rules: the current screen size (automatically detected), a set size in pixels, or a set number of tiles. The tool will automatically convert between each system for you, and it will let you know the size of the final image in both tiles and pixels.

Other new features and updates in version 5.0

Other updates in v5.0 include:

  • New “Duplicate Image” tool. Perfect for making a working copy of an image without fear of overwriting the original. (Thanks to Achmad Junus for the suggestion!)
  • Drag-and-Drop compatibility. Drag images from your desktop or file manager onto PhotoDemon, and it will open them all automatically. (Thanks to Kroc of camendesign.com for the suggestion!)
  • Auto-Enhance overhaul. All four auto-enhance tools (contrast, highlights, midtones, shadows) have been rewritten from scratch using completely new algorithms. I think you’ll find them way more useful than the old tools.
  • Improved mosaic tool. Faster, higher quality, and mosaics can now be as large as the image or as tiny as one pixel in either dimension.
  • Improved handling of edge pixels for all convolution filters (blur, soften, sharpen, etc)
  • Improved manual color reduction algorithms (faster and higher quality)
  • New histogram equalization form. Equalize any combination of color channels (red, green, blue) and luminance with real-time previews.
  • DPI-aware images mean no more distortion at 120dpi – a big improvement for people using “large font” settings.
  • Fixes for users of the “Classic Theme” in modern versions of Windows. Your menus should look much better in this release.
  • Improved bug reporting system and online form to match.
  • Tons of miscellaneous bug fixes, tweaks, and optimizations. For a full list of changes, visit https://github.com/tannerhelland/PhotoDemon/commits/master

In Conclusion…

I hope you enjoy the many improvements in version 5.0. As always, feel free to contact me with any feedback you might have.

Announcing PhotoDemon 4.4 – Now With Update Notifications, Improved Histogram, and More

Summary

PhotoDemon v4.4 is now available. It has a lot of cool new features. Download it here.

New Feature: Update Notifications

The most important update in version 4.4 is the addition of an automatic update notifier.

PhotoDemon's new update notifier
PhotoDemon’s new update notifier.

By default, PhotoDemon will check for updates whenever the software is run. Automatic update checks can be disabled from the Edit -> Preferences menu. You can also manually check for updates by going to Help -> Check for Updates.

I’m not sold on the layout of the update notification form – particularly the center alignment of the version numbers, which looks off due to the white space on the right-hand side – so its appearance may change in future versions, but at least this first draft conveys all the essential information.

Finally, note that this is merely an update notifier, not an automatic updater – clicking the “Yes” button will only open the PhotoDemon download page in your browser. It will not download the update for you, and it will not overwrite your current copy of the software. This is my preferred behavior for portable applications, but I am open to suggestions for better methods.

New Feature: Helpful Undo/Redo Text

The left-hand bar in v4.4 has been redesigned from version 4.3:

Comparison of v4.3 and v4.4 left-hand bar
v4.3 is on the left, v4.4 is on the right

The new, more compact version is in preparation for adding additional tools to the bottom section of the left-hand bar. It was also done as part of the new “friendly text” version of the Undo/Redo buttons:

new Undo/Redo interface
PhotoDemon’s helpful new Undo/Redo text.

I tried displaying the full text of the Undo/Redo action in the Undo/Redo buttons themselves, but as some of the descriptions are rather long, the button text would get pushed onto multiple lines (or off the button entirely!) making them look terrible. So the current implementation is: hover over the Undo/Redo button to see what action will be performed. As you can see, the Edit menu also contains a full-text description of Undo/Redo behavior.

Redesigned Histogram

With version 4.4, I don’t think it’s biased to say that PhotoDemon provides the best image histogram tool in the business:

PhotoDemon 4.4's redesigned histogram
PhotoDemon 4.4’s redesigned histogram

Individual channels can now be hidden or displayed in any combination. (The histogram will automatically adjust its maximum and minimum values accordingly.) This is useful for comparing just two color channels, for example, or comparing a single color channel against luminance.

The histogram now provides a “use smooth lines” option. This enables two features: antialiased lines (which VB does not do natively, so it’s a custom implementation), and cubic spline interpolation. Here’s an example of the aesthetic difference this makes:

Comparison of histogram render methods
Makes a difference, doesn’t it?

The new histogram interface provides a logarithmic rendering option. Images that are very dark or very bright will blow out the histogram at one end or the other, making it very difficult to see what’s happening in those ranges. Take the histogram of this beautiful FF7 fan art from pixiv.net user マップ, for example:

Image in need of a logarithmic histogram

Logarithmic histogram in action

Classic features like displaying the values of the histogram level under the cursor are still present, and you can still export the histogram image to an 8-bit PNG, GIF, or BMP file.

Finally, as of version 4.4 PhotoDemon’s histogram window is now non-modal. This means that you can leave the histogram window open while loading/saving/manipulating images, and the window will automatically refresh itself when necessary. Perform a filter or color operation and the histogram will update to reflect those changes; Undo a previous action and it will also update, making it very useful for comparing the effects of various filters.

As part of these updates, the histogram code has been newly refactored and optimized, so it’s fast and extremely low-resource, even when left open during image operations. All histogram data is pre-calculated, so when you change rendering options (such as enabling/disabling channels or switching between logarithmic and regular representation) the new histogram is instantly redrawn without requiring a recalculation of the raw data.

I’m not done with histogram updates, but v4.4 provides a great improvement over v4.3.

Redesigned Grayscale Interface and New Grayscale Algorithms

The grayscale conversion form has been completely redesigned in v4.4:

Redesigned grayscale interface
Special thanks to pixiv user ぴよな*ティア for the image in the preview.

Grayscale conversion was one of the last features to lack an instant-preview option, but no longer – you can now see real-time previews of the various grayscale algorithms.

I have also ported over all seven of the grayscale conversion algorithms from my standalone grayscale project, some of which were not present in PhotoDemon. The full list of available grayscale conversion methods now includes:

  • Averaging
  • ITU standard (adjusting for cone density in the human eyes)
  • Desaturation (HSL color space)
  • Decomposition to maximum or minimum values
  • Single color channel reduction
  • Reduction to specific # of gray shades
  • Reduction to specific # of gray shades with dithering

PhotoDemon defaults to the ITU standard method, which is the best choice for people who have no idea what these various options mean. :) For a full discussion of how these methods work and why some are preferable to others, see my aforementioned in-depth grayscale article.

Finally, the reduce-to-specific-number-of-shades option can now be used to reduce an image to black and white (two shades). Previously it required three shades or more. That said, I still advise using PhotoDemon’s specific “convert to black and white” menu option, which provides more control over 2-color reduction.

Other miscellaneous updates and bugfixes

Other updates in v4.4 include:

  • The system hand cursor is now automatically applied to all clickable objects. This was previously done manually, and because VB isn’t smart about sharing resources, a hand cursor was stored in multiple places throughout the .exe. The new automated feature meant I could remove those references, so the new v4.4 .exe is actually smaller than v4.3, despite including a bunch of additional features. Windows Vista/7 users will also get a much prettier hand icon.
  • Batch conversion now has a more robust error handler. This is in preparation for the addition of an all-new batch conversion wizard, which didn’t make the cut for 4.4 but should be included in 4.5
  • Miscellaneous bug fixes related to save prompting, MDI maximizing, and more. See a full list of updates at PhotoDemon’s commit page on github.

In Conclusion…

I hope you enjoy the changes in version 4.4. As always, feel free to contact me with any feedback you might have.

Where does Microsoft make money? (Updated 2012)

THIS INFORMATION IS OUTDATED. Click here to see the updated 2013 report.

As in past years, all information in this report is taken from Microsoft’s publicly available 2012 10-K filing. Numbers may vary from past reports. When Microsoft moves products between revenue categories, they retroactively adjust the totals for past years so that year-to-year comparisons are accurate. This article uses 2010 and 2011 values as calculated in the 2012 report. All values are in USD.

If you’ve read my past reports, feel free to skip down to the charts. If this is your first time here, let me provide a quick explanation of how Microsoft breaks down its earnings.

Microsoft Total Revenue and Operating Income (June 2011 – June 2012)

Total Revenue: $73,723,000,000
Operating Income: $21,763,000,000

Total Revenue is the total amount of money Microsoft takes in from normal business operations.

Operating Income is calculated as (Operating Revenue – Operating Expenses). In other words, “Operating Income” is the profit made from normal business operations. (A more formal definition is available from Investopedia: “Operating income would not include items such as investments in other firms, taxes or interest expenses. In addition, nonrecurring items such as cash paid for a lawsuit settlement are often not included. Operating income is required to calculate operating margin, which describes a company’s operating efficiency.”)

Operating Income is particularly important when looking at a company like Microsoft. Certain Microsoft divisions take in a great deal of money, but they also require much higher costs to operate. Therefore, it is important to look at not just how much money a certain division brings in – but at how much it costs to operate that division.

Microsoft total revenue and operating income, 2010 - 2012
Long story short: Microsoft’s 2012 revenues were up over 2011, but operating income fell.

Microsoft Revenue and Operating Income by Division (June 2011 – 2012)

Microsoft products (and earnings) are divided into five divisions: Windows & Windows Live, Microsoft Business, Server and Tools, Entertainment and Devices, and Online Services. The types of products and services provided by each segment are summarized below:

  • Windows and Windows Live – Windows operating system, Windows Live applications and web services, Microsoft PC hardware products.
  • Microsoft Business – Microsoft Office (including Office Web Apps and Office 365), Microsoft Exchange, Microsoft SharePoint, Microsoft Lync, Microsoft Office Project and Office Visio, and Microsoft Dynamics ERP and CRM.
  • Server and Tools – Windows Server operating system, Windows Azure, Microsoft SQL Server, SQL Azure, Visual Studio, Silverlight, Windows Intune, Windows Embedded, System Center products, Microsoft Consulting Services, and Premier product support services.
  • Entertainment and Devices – Xbox 360 console, games, and accessories (e.g. Kinect), Xbox LIVE, Windows Phone. In 2012, Microsoft also added Skype to this division.
  • Online Services – Bing, Microsoft adCenter, MSN, and Atlas online tools for advertisers.

(Note: these divisions are pretty much identical to 2011, with the exception of Skype being added to Entertainment and Devices.)

Here are the 2011-2012 revenue and operating income values for each division, in USD. Note that the number in parentheses is the percentage change between 2011 and 2012.

Windows and Windows Live
Revenue: $18,373,000,000 (-3%)
Operating Income: $11,460,000,000 (-6%)

Business (Office, Exchange, SharePoint)
Revenue: $23,991,000,000 (+7%)
Operating income: $15,719,000,000 (+7%)

Server and Tools (Windows Server, Microsoft SQL, Visual Studio)
Revenue: $18,686,000,000 (+12%)
Operating Income: $7,431,000,000 (+18%)

Entertainment and Devices (XBox 360/LIVE, Windows Phone)
Revenue: $9,593,000,000 (+8%)
Operating income: $364,000,000 (-71%)

Online Services (Bing, MSN, Hotmail)
Revenue: $2,867,000,000 (+10%)
Operating income: $-8,121,000,000 (*)

(* – Microsoft marks the large difference between Online Services’ 2011 and 2012 operating income as “not meaningful.” The explanation: “OSD’s fiscal year 2012 operating loss reflects a goodwill impairment charge of $6.2 billion, which we recorded as a result of our annual goodwill impairment test in the fourth quarter. The non-cash, non-tax-deductible charge related mainly to goodwill acquired through our 2007 acquisition of aQuantive, Inc.”)


Total Revenue Charts – 2012

Microsoft revenue by division 2012 (raw values)
Microsoft total revenue by division in 2012. (Amounts in millions USD.)

 

Microsoft revenue by division 2012 (percentages)
Microsoft total revenue by division for 2012, as percentages. Note that in terms of pure revenue, Microsoft Business outperforms every other division. This chart is also nice for showing just how little XBox, Bing and – at present – Windows Phone matter to Microsoft’s current cash flow. That may change in the future, but for now it is all about Office, Windows, and Server/Tools.

Operating Income Chart – 2012

Microsoft operating income by division 2012
Microsoft operating income, by division, for 2012. (Amounts in millions USD.) Note that Online Services represents an $8.1 billion dollar LOSS. Microsoft Business is far and away the most profitable division, while Server and Tools – which brought in as much revenue as the Windows division in 2012 – represents significantly less profit. Again, note how insignificant XBox and Windows Phone are from a profit standpoint.

Year-over-year comparisons (2010-2012)

Microsoft revenue by division (2010-2012)
Microsoft revenue by division for the years 2010, 2011, and 2012. Overall revenue continues to trend upward, despite Windows sales falling for two years straight. It will be very interesting to see how the October launch of Windows 8 affects next year’s numbers.

 

Microsoft operating income by division (2010-2012)
Microsoft operating income by division for the years 2010, 2011, and 2012. Unlike revenue, operating income varies dramatically from year to year. Microsoft Business dominated profits in 2012, while Online Services continued to hemorrhage a frightening amount of money. Entertainment and Devices also took a huge hit from 2011, so don’t be surprised if Microsoft becomes increasingly aggressive about improving profitability of XBox and Windows Phone in 2012.

Announcing PhotoDemon: A Fast, Free, Open-Source Photo Editor and Image Processor

PhotoDemon screenshot
PhotoDemon v4.2 in the midst of a massive batch conversion (1643 files)

tl;dr – I’ve spent 12 years working on an advanced image processing program. (Think PhotoShop, but without any on-canvas painting tools.) The software is now available under the title “PhotoDemon.” It is fast, free, completely open-source (BSD licensed), and it provides a number of useful features, including macro recording and automated batch conversion. You can download it here.

I can’t often say that a blog post has been 12 years in the making… but believe it or not, this post has taken me that long to write.

Many years ago, when I was but a lowly high school student, I legitimately believed that I alone could produce the world’s greatest video game. It was going to be epic in every possible way – immersive 3D graphics, fully orchestrated musical score, hundreds of pages of witty dialogue. I was going to program the whole thing myself in Visual Basic 6.0, and it was going to be AWESOME.

(ROFL)

This might shock you, but that game never came to fruition.

Fortunately, my delusional teenage aspirations weren’t entirely a waste – I did end up writing many hours of original music for the game, and I also produced a suite of useful development tools. One of those tools was called the GenesisX Image Studio, after my one-man GenesisX Production Company. (Yes, that name sounded cool to my teenage mind.) The purpose of GenesisX Image Studio was to convert 24-bit image files to the game’s custom 8-bit Genesis X Format.

Perhaps you recall, but back in the year 2000 bandwidth was hard to come by, and distributing a game chock full of large 24-bit images over the Internet simply wasn’t feasible. GIF images were still under patent protection so there were concerns about using them, and PNG wasn’t widely known or supported. So I decided to write my own image format, and this was the program capable of converting JPEGs and BMPs to that:

GXF Compressor screenshot
Here’s a screenshot of the GenesisX Image Studio. I know – it burns the eyes a little. Don’t you love the red/black gradient? It seemed so edgy at the time. (facepalm)

While the GXF Compressor was hideous to look at, it included some interesting code, including a rather clever interactive palette editor. That palette editor was at the heart of the Genesis X Format. It worked by taking 256-color images and blending low-frequency colors at a ratio of their occurrences within the image. This way, it was possible to get a 256-color image down to 128 colors or less with very little degradation; the image would then be RLE compressed and optionally zLib compressed, and it was capable of producing downright tiny files.

GXF Palette Editor
The GenesisX Palette Editor. I’m not sure why I felt the need to plaster a bright red copyright message on the form… I’m fairly certain no one was interested in stealing my painfully amateurish code.

When the ultimate game project associated with this software died, I continued to peck away at the image studio, mostly because I enjoyed learning about image processing and the software already provided a framework for things like loading and saving images, zooming and scrolling them, and a rudimentary set of filters. Over time, I eliminated the 256-color feature set and focused only on 16 million color support. Eventually the ridiculous “GenesisX” moniker was dropped, and the project was renamed “DemonSpectre Image Workshop.” (DemonSpectre was my online alias at the time.)

DemonSpectre Image Workshop
By 2002, the project had become slightly less hideous. The red/black gradient was replaced by the blue/black gradient made famous by InstallShield, and a thoroughly useless logo was added to the left-hand side. The code base also grew to include a variety of new filters and processing techniques.

In 2002, Microsoft introduced the first version of Visual Studio .NET, effectively obsoleting the COM-based VB6 overnight. I was in university by then, and had become very aware that VB was not the right language for a programmer who wanted to be taken seriously in the U.S. job market. So I learned C++, java, and Perl, though I retained a love for classic VB, in large part because it was the language that got me into programming in the first place.

The next 8-9 years saw slow, incremental upgrades to the software, usually the result of a random night or weekend when I was fed up with work and needed to focus on something not-work-related. Eventually I renamed the software “VB Photoshop” (no copyright problems there!), then later PhotoDemon, a mash-up of my old DemonSpectre moniker and the fact that the software had grown to focus primarily on photo editing.

In fact, my interest in digital photography led to many of the program’s best features, since I used PhotoDemon to implement tools that other image editing programs lacked or implemented poorly. (I’m looking at you, PhotoShop batch conversion!) Since its inception, PhotoDemon also served as a testbed for my image processing work in other programming languages, because for all its flaws, classic VB is unbeatable as a rapid prototyping language. I still use it for first-implementation tests of obscure features or filters, simply because I can go from pseudocode to real-time implementation in minutes (versus hours in java, and days/months in C). And because VB6 compiles down to native code (unlike the interpreted P-code of earlier versions), it’s perfect for prototyping image processing code, which often needs to execute in real-time.

PhotoDemon v4.2 menu screenshot
PhotoDemon has come a long way from its original GenesisX Image Studio roots. The current version looks quite nice, and it includes features I find lacking in other software – such as extensive accelerator (“hotkey”) support. For those who don’t utilize accelerators, the menus are designed to maximize discoverability. IMO they’re a significant improvement over most image editing software menus.

Because I continued to receive a surprising amount of traffic to my VB-oriented programming site, I would periodically strip interesting features out of PhotoDemon and publish them independently. In fact, most of my open-source programming projects are merely subsets of PhotoDemon’s codebase. (And it’s a surprisingly large codebase – over 30,000 lines – and that’s not including the 3rd-party DLLs it relies on for extra functionality.)

Every now and then, I’ll receive an email from a poor programmer who’s stuck supporting a legacy VB6 application and has consequently stumbled across my site. These emails always brighten my day, and they’re the reason I still provide VB6 projects despite the language being “dead” for more than 10 years. (Although “dead” is a relative term – Microsoft’s extended support lasted until 2008, and they have promised “it just works” compatibility for VB6 applications FOR THE LIFETIME of Windows 8. I know people have their criticisms of Microsoft, but no major tech company is half as good as they are when it comes to supporting legacy software. Hats off to Microsoft for that.)

Occasionally, these emails will ask me if I have a single project that condenses my many image processing techniques into a single piece of software. For ten years, my response to this question has been a vague, teasing, “maybe I do – you’ll have to wait and see!” I’m not sure why I’ve never just tell people about PhotoDemon… probably because they would pester me for copies of the code, and I hate sending out .zip files of large source directories, especially when I haven’t made up my mind about how I want to license said code.

But this summer, as I was sending out yet another one of these vague email responses, it struck me that I’d spent the past ten years hinting at PhotoDemon but never really thinking seriously about when it might live somewhere besides my hard drive. Wasn’t it time to seriously commit to getting the project in a workable state? (Anyone who knows me shouldn’t find this surprising – my motto has always been “better late than never,” and boy does this project meet that definition!)

So I committed, then and there, to getting PhotoDemon into a workable state. My last three months have been spent cleaning up its code base, stripping out useless functions and features, writing documentation, and coaxing it to work with modern Windows visual styles – no small feat, considering VB6 never worked with Windows XP visual styles, let alone Windows 7.

PhotoDemon current version screen shot
PhotoDemon, as it looks in August 2012. Note the use of Windows 7 visual styles, along with full MDI support. Also – no hideous background gradient! :)

Because I’m a glutton for punishment, I also got PhotoDemon working with modern version control software. (Here it is on GitHub.) I wonder if I’m the first person to try and get a massive VB6 codebase working properly with Git… Surprisingly, it does work, though it takes some tweaking thanks to VB’s strange intermixing of text and binary files. Maybe someday I’ll document what I did. Then again, maybe not – I’m not sure I want people trying to set up legacy VB projects with GitHub, lol.

After getting the code to a pleasantly robust state, I put up a preliminary project page for PhotoDemon on this site. That was six weeks ago. Thus far it seems to have been well-received among the VB programmers who frequent my site, and with the help of those programmers, many miscellaneous bugs have been squashed. After a rigorous few weeks of testing, I think PhotoDemon is finally stable enough to warrant broader use.

And that’s why this blog post exists.

Over the next few weeks, possibly months, I plan on releasing a series of “developer diaries” that discuss PhotoDemon’s features and design in detail. I don’t know many projects with a 12-year development time that spans from the developer first learning to program to becoming a professional coder, and I think my experiences could be useful for other young programmers looking to embark on their own open source project. Also, some of PhotoDemon’s more advanced capabilities – such as macro recording and playback – represent unique design challenges, and I think it could be worthwhile to discuss the implementation hurdles I faced in hopes of helping other programmers build such features right on their first try.

PhotoDemon v4.2 print dialog
PhotoDemon’s current interface aims to find that sweet spot between minimalism and power. For example, here’s the print dialog. I find most print dialogs to be woefully over-engineered, so this one provides only the options I use on a regular basis. Also, I just noticed that the “Orientation” label is misaligned vertically. D’oh! Better go fix that…

But for now, here’s what’s worth mentioning: PhotoDemon is stable, and I’d love your feedback on it. It’s designed as a portable app, meaning no installer is required. Just download the .zip, extract it, and run PhotoDemon.exe. (Not a Windows user? PhotoDemon should work with the latest stable release of Wine.)

Input is welcome from programmers and non-programmers alike. To download just the executable, use this link:

Download PhotoDemon (software only, no source code)

If you want the program AND its complete source code, download it from PhotoDemon’s GitHub page:

Download PhotoDemon (with complete source code)

A GitHub account is not required. Simply click the “ZIP” button with the cloud-and-arrow icon to download the source in standard VB6 format. (The ZIP button is just below the project description, in the top-left quadrant of the page.)

Issues can be submitted from the “Help” menu within PhotoDemon, or by visiting the Issues page, or by simply sending me an email.

Stay tuned for posts describing PhotoDemon’s (quite large) feature set in detail, as well as in-depth guides for its advanced features, including macro recording and batch conversion.

Finally, note that PhotoDemon is updated regularly. I tend to make commits on at least a weekly basis, and often more frequently than that. For the most up-to-date version of the software, download it from GitHub.

Thanks for your interest, and I hope you enjoy the software.

Where does Microsoft make money? (Updated 2011)

THIS INFORMATION IS OUTDATED. Click here to see the updated 2012 report.

I’ve done this for Microsoft’s 2009 and 2010 fiscal years, so I may as well add 2011’s to the list.  (Microsoft’s fiscal year ends in June, so I’ll be adding 2012’s data when it becomes available.)

As before, all information in this report is taken from Microsoft’s publicly available 2011 10-K filing.  Numbers may vary slightly from past reports; for reasons I don’t fully understand, Microsoft retroactively adjusts their exact earning numbers in subsequent years.  This article uses 2009 and 2010 values as calculated in the 2011 report.  All values are in USD.

If you’ve read my report on past years (2009 or 2010) then feel free to skip down to the charts.  If this is your first time here, let me provide a quick explanation of how Microsoft breaks down its earnings.

Microsoft Total Revenue and Operating Income (June 2010 – June 2011)

Total Revenue: $69,943,000,000
Operating Income: $27,161,000,000

For those who don’t know, Total Revenue is the total amount of money Microsoft takes in from normal business operations.

Operating Income is calculated as (Operating Revenue – Operating Expenses). In other words, “Operating Income” is the profit made from normal business operations. (A more formal definition is available from Investopedia: “Operating income would not include items such as investments in other firms, taxes or interest expenses. In addition, nonrecurring items such as cash paid for a lawsuit settlement are often not included. Operating income is required to calculate operating margin, which describes a company’s operating efficiency.”)

Operating Income is particularly important when looking at a company like Microsoft.  Certain Microsoft divisions take in a great deal of money, but they also require much higher costs to operate.  Therefore, it is important to look at not just how much money a certain division brings in – but at how much it costs to operate that division.

Microsoft Revenue and Operating Income by Division (June 2010 – 2011)

Microsoft products (and earnings) are divided into five divisions: Windows & Windows Live, Microsoft Business, Server and Tools, Entertainment and Devices, and Online Services. The types of products and services provided by each segment are summarized below:

Windows and Windows Live – Windows operating system, Windows Live applications and web services, Microsoft PC hardware products.

Microsoft Business – Microsoft Office (including Office Web Apps and Office 365), Microsoft Exchange, Microsoft SharePoint, Microsoft Lync, and Microsoft Dynamics ERP and CRM.

Server and Tools – Windows Server operating system, Windows Azure, Microsoft SQL Server, SQL Azure, Visual Studio, Silverlight, Windows Intune, Windows Embedded, System Center products, Microsoft Consulting Services, and Premier product support services.

Entertainment and Devices – Xbox 360 console, games, and accessories (e.g. Kinect), Xbox LIVE, Windows Phone.

Online Services – Bing, Microsoft adCenter, MSN, and Atlas online tools for advertisers.

(Note: these divisions are roughly the same as 2010, with the following two exceptions: in 2011, Microsoft hardware products were moved from Entertainment and Devices to Windows and Windows Live.  Also, Windows Embedded device OS was moved from Entertainment and Devices to Server and Tools.)

The 2010-2011 Revenue and Operating Income for each division, in USD, is as follows:

Windows and Windows Live
Revenue: $19,024,000,000
Operating Income: $12,281,000,000

Business (Office, Exchange, SharePoint)
Revenue: $22,186,000,000
Operating income: $14,124,000,000

Server and Tools (Windows Server, Microsoft SQL, Visual Studio)
Revenue: $17,096,000,000
Operating Income: $6,608,000,000

Entertainment and Devices (XBox 360/LIVE, Windows Phone)
Revenue: $8,913,000,000
Operating income: $1,324,000,000

Online Services (Bing, MSN, Hotmail)
Revenue: $2,528,000,000
Operating income: $-2,557,000,000


Total Revenue Charts

Microsoft revenue by division (raw values)
Microsoft total revenue by division in 2011. (Amounts in millions USD.)

 

Microsoft revenue by division (percentages)
Microsoft total revenue by division for 2011, as percentages. Note that in terms of pure revenue, Microsoft Business outperformed every other division.

Operating Income Chart

Microsoft operating income by division
Microsoft operating income, by division, for 2011. (Amounts in millions USD.) Note that Online Services represents a $2.5 billion dollar LOSS. Also note that Microsoft Business remained the most profitable division, while Server and Tools - which brought in almost as much revenue as the Windows division in 2011 - represented significantly less profit overall.

Year-over-year comparisons (2009-2011)

Microsoft revenue by division (2009-2011)
Microsoft revenue by division for the years 2009, 2010, and 2011. Overall revenue increased slightly in 2010 and dramatically in 2011, but the overall percentage represented by each division did not change by an appreciable amount.

 

Microsoft operating income by division (2009-2011)
Microsoft operating income by division for the years 2009, 2010, and 2011. Unlike revenue, operating income varies dramatically from year to year. Microsoft Business dominated profits in 2011, while Online Services continued to hemorrhage a frightening amount of money. It's also worth noting that while Entertainment and Devices represents a small amount of Microsoft's total profit, that division doubled in profitability from 2010 to 2011.

Where does Microsoft make money? (Updated 2010)

THIS INFORMATION IS OUTDATED. Click here to see the updated 2012 report.

Since my previous article on this topic has received a lot of attention, I figured I should update the numbers for 2010.

Before I post these numbers (which are publicly available via Microsoft’s 10K filing), let me clearly state that I do not compile this information in order to advocate a pro- or anti-Microsoft agenda. My primary purpose in compiling this information is to help individuals discuss Microsoft with some level of objectivity.

So without further ado, here’s a simplified version of “where does Microsoft make its money (2010).”

Total Revenue and Operating Income (June 2009 – 2010)

Total Revenue: $62,484,000,000
Operating Income: $24,098,000,000

For those who don’t know, Operating Income = Operating Revenue – Operating Expenses. In other words, “Operating Income” is the profit made from normal business operations. (A more formal definition is available from Investopedia: “Operating income would not include items such as investments in other firms, taxes or interest expenses. In addition, nonrecurring items such as cash paid for a lawsuit settlement are often not included. Operating income is required to calculate operating margin, which describes a company’s operating efficiency.”)

Revenue and Operating Income by Division (June 2009 – 2010)

Microsoft’s products are divided into five divisions: Windows & Windows Live (formerly “Client”), Server and Tools, Online Services, Microsoft Business, and Entertainment and Devices. The types of products and services provided by each segment are summarized below:

Windows and Windows Live – Windows operating system: Windows 7, including Home Basic, Home Premium, Professional, Ultimate, Enterprise, and Starter Edition; Windows Vista, including Home Basic, Home Premium, Ultimate, Business, Enterprise and Starter Edition; and Windows XP Home. Windows Live suite of applications and web services.

Server and Tools – Windows Server operating system; Windows Azure; Microsoft SQL Server; SQL Azure; Visual Studio; Silverlight; System Center products; Biz Talk Server; Microsoft Consulting Services; Premier product support services; and other products and services.

Online Services Business – Bing; Microsoft adCenter; MSN; and Atlas online tools for advertisers and publishers.

Microsoft Business Division – Microsoft Office; Microsoft SharePoint; and Microsoft Dynamics ERP and CRM, as well as Microsoft Office Web Apps, which are the online companions to Microsoft Word, Excel, PowerPoint and OneNote.

Entertainment and Devices Division – Xbox 360 console and games; Xbox LIVE; Windows Phone; Windows Embedded device operating system; Zune; Mediaroom; and numerous consumer software and hardware products (such as Mac Office, mice, and keyboards); and Windows Automotive.

Microsoft’s previous fiscal year (June 2009-2010) was a particularly interesting one, with major headlines including the Windows 7 launch, Office 2010 launch, a redesigned XBox 360, Windows Phone 7, a new search and advertising agreement with Yahoo!, and the first full year of Bing-branded services. Some of these announcements came late in the fiscal year, which can indicate significant development cost without corresponding sales (keep that in mind).

The 2009-2010 Revenue and Operating Income for each division, in USD, is as follows:

Windows and Windows Live
Revenue: $18,491,000,000
Operating Income: $12,977,000,000

Server and Tools (Windows Server, Windows Azure, Visual Studio, Silverlight)
Revenue: $14,866,000,000
Operating Income: $5,491,000,000

Online Services (Bing, MSN, Hotmail)
Revenue: $2,199,000,000
Operating income: $-2,355,000,000

Business (Office, SharePoint, Dynamics ERP/CRM)
Revenue: $18,642,000,000
Operating income: $11,776,000,000

Entertainment and Devices (XBox 360/LIVE, Zune, Windows Phone, hardware)
Revenue: $8,058,000,000
Operating income: $679,000,000