Silly, fun and useful things to do with Resolver One
  • HOME
  • About
  • Articles
  • Fun
  • Snippets
  • Disclaimer
  • Useful Links

Site by Voidspace

Email Michael

Download Resolver One

RSS Feed RSS Feed

Resolver Hacks contains information and code for doing fun and useful things with Resolver One. This site is created and maintained by Michael Foord, not by Resolver Systems. Please read the disclaimer before using any of the code on this site.

Site Built with rest2web

Creative Commons License

IronPython Wiki

IronPython in Action IronPython in Action

Resolver as Image Viewer

Viewing images with Resolver

An image is a rectangular grid of pixels, each with a single colour. By coincidence, with Resolver we have a grid of rectangles where we can control the colour of each cell. We can also change the row height and column width to make them a little more 'pixel-shaped'.

The image viewer spreadsheet turns Resolver into a very inefficient image viewer.

  • Download the Image Viewer Spreadsheet (zipfile 8kb)

This spreadsheet has several 'features':

  • The grid is turned off so that you can see the image without lines all over it
  • You can control individual pixel width and height. The default is 2, 2 - so the image displayed is magnified by two in both dimensions
  • It caches the image in between recalculations
  • It has a button that allows you to select a new image to load

(WARNING: Don't load big images! About 60x60 pixel pictures are the best to view. The grid isn't really designed to do this and it has to do a lot more work than is reasonable.)

A cute cat loaded into the image viewer.

How it Works

The image is loaded using the Bitmap class.

This exposes a Height and a Width property, and we can fetch the colour of individual pixels with the image.GetPixel(x, y) method.

The code iterates over every pixel in the image, setting the BackColor of the corresponding cell in the grid. We control the size of the cells by setting the width and the height of the rows and columns; sheet.Cols[colIndex].Width = width.

xMod = 4
yMod = 9
for x in range(image.Width):
    colIndex = x + xMod
    sheet.Cols[colIndex].Width = int(width)

    for y in range(image.Height):
        rowIndex = y + yMod
        if x == 0:
            # We only need to set the row height once
            sheet.Rows[rowIndex].Height = int(height)

        color = image.GetPixel(x, y)
        sheet.Cells[colIndex, rowIndex].BackColor = color

Loading a new image is done with the OpenFileDialog class from Windows Forms. In general you shouldn't use Windows Forms controls from user code, but in fact the file dialogs and system message box are probably safe. Having chosen an image, it is loaded and cached by the Cache module. This means that the image doesn't need to be reloaded for every change, just the first time and when you change images.

When a new image is loaded, a recalculation is then triggered by sending an 'F9' keypress (which is definitely cheating).

Anyway, this spreadsheet has no practical use whatsoever and is only proof that you can do silly things with Resolver.

By the way, if you turn the grid back on, this is what you get:

Avocados in the image viewer, with the grid on.


Hosted by Webfaction

Return to Top

Last edited Mon Dec 10 18:34:20 2007.

Copyright ©2007 Michael Foord. All rights reserved. Design by Elemental Works. Logo by FuchsiaShock. Valid XHTML & CSS.

This work is licensed under a Creative Commons License.