As a radiologist, I spend my working life interacting with medical images in the form of DICOM files through various software viewers. There are lots of improvements I’ve wanted to make to these viewers as well as other side project ideas I’ve had that would require reading / manipulating DICOMs. My favoured programming language is Xojo but this language provides no native way of reading DICOMs nor are there any available third party solutions to do so (at least at the time of writing). I decided that it would be a “good” idea to try to write my own module not only to achieve my goal of later using this module in future projects but also as a way to better understand the underlying software that powers my day-to-day life.

I call this module DICOMKit.

To say writing DICOMKit has been a challenge would be an understatement. The DICOM standard is very complex and the published documentation (whilst exhaustive) is not an easy read. There are a few open source projects out there in several languages (C, C++, Python, Javascript, to name but a few) but even perusing their source code is time consuming and, at times, infuriating. I have made sure that the source code for DICOMKit is extremely well (some might say excessively) commented throughout to allow others to learn from it.

At the time of writing, DICOMKit is capable of checking if a file is in the DICOM format, parsing it into its constituent elements and of extracting the image(s) stored within it as a Xojo Picture object. It currently only supports images stored in an uncompressed format although I do want to support other formats (mostly lossless JPEG and JPEG Baseline) in the future once I wrap my head around the decompression algorithms.

DICOMKit is 100% native Xojo code and does not require any third party dependencies, even though the project would progress faster with them. DICOMKit also compiles for all platforms supported by Xojo, including iOS and the Raspberry Pi.

It’s my intention to write a series of articles about the technical structure of DICOM files at some point in the future. I provide no time frame for this to happen.

Finally, whilst technically DICOMKit is open source, I’m not looking for it to be a truly collaborative project. I don’t mind you modifying or forking it and I do hope that you’ll find it useful and report bugs about them. At the same time I don’t plan on accepting patches for it. I prefer to keep things under my control and don’t have the time to worry about managing a burgeoning open source endeavour.

Of course, if there’s a patch or issue that needs to be fixed, as long as there is an understanding that I will re-implement any patch you send (which implies, among others, that you should explain what the patch’s code does) feel free to send it to me. However, I don’t promise that I’ll actually implement it. If I do decide to use it, it’ll be as a source of inspiration and a point of reference for the feature or bug fix that you need implemented.

I seem to be on a bit of a roll vis-a-vis Xojo syntax highlighting. I’d like to announce the release of a language definition for Xojo for the Prism syntax highlighting engine.

Why have I written another language file for Xojo? Well, I’ve been writing a lot in Markdown and have recently started using the fabulous (and free) Macdown app to do so. The only shortcoming I found with it was that, whilst able to highlight code from a number of programming languages, it couldn’t highlight Xojo code. Given the highlighting engine of Macdown is powered by Prism, I figured I’d have a go at writing a definition file for it.

How do I use it with Macdown?

You’ll need to place the definition file Macdown’s application bundle. You can find this by right-clicking on the Macdown app in your Application folder and selecting Show Package Contents. Put the file in: Contents > Resources > Prism > components. You’ll need to restart Macdown if it’s open for the new language to be recognised.

To highlight Xojo code in a Xojo document, just wrap it in a code fence as below:

``` xojo

Dim s As String = “Hello World"



The language file is hosted over at GitHub. Feel free to modify / improve it as you see fit.

I’m pleased to announce the release of a free custom language file for GeSHi for the Xojo programming language. GeSHi (the Generic Syntax Highter) is a PHP library that can highlight the syntax of a number of programming languages. It’s also available as a plugin for WordPress (as WP-Syntax). This language file adds support for Xojo to the highlighting engine.

Why might I use this?

If you blog about Xojo, you’ll probably want to display some example code. If you use Wordpress, you can use a combination of the WP-Syntax plugin and this language file to highlight Xojo code in your posts.

How do I use it?

Simply install the WP-Syntax plugin and then add the Xojo language file to the geshi folder within the wp-syntax folder of the plugin. Then just wrap any Xojo code in your posts with <pre lang="xojo"></pre> tags and the plugin will highlight the code. You can also optionally add line="1" to show line numbers (omit to hide them). Adding highlight="4" will highlight the fourth line of code.

What does it support?

The language file supports almost everything that the Xojo IDE does. It will correctly highlight the following items in code (in the default Xojo IDE colours):

  • Keywords (current up to Xojo 2014 release 2.1)
  • Primitive data types
  • Integers
  • Floating point numbers
  • Strings
  • Comments
  • Hex, binary and octal representation of numbers

Known issues

  • Currently unable to highlight URLs within comments like the Xojo IDE does
  • Does not highlight the individual red, green and blue components of a &c (color) literal data type


GeSHi requires that CSS styles for each highlighted component in a syntax are hard-coded into the language file. At present, these colours mimic those chosen by default in the Xojo IDE:

  • Keywords (#0000FF)
  • Strings (#6500FE)
  • Integers (#326598)
  • Floating point numbers (#006532)
  • Comments (#7F0000)
  • Hex (&h) numbers (#326598)
  • Binary (&b) numbers (#326598)
  • Octal (&o) numbers (#326598)

Within the language file, I’ve separated Keywords (such as Dim, While) from primitive data types (e.g. Double, String) and compiler directives (e.g. #pragma, #If) so you can style them differently if you’d like. By default, they have the same styling (color: #0000FF) as keywords.

To change a style, simply change the CSS style property for the type (e.g. KEYWORDS) within the STYLES array in the PHP language file.

Further tweaks

I dislike GeSHi’s default behaviour of adding alternating line colours so I added the following custom CSS to my Wordpress theme stylesheet to remove it:

/* Remove the alternating line background colours in code (added by the WP-Syntax plugin) */
.wp_syntax pre {
    background: #FCFCFC !important;
    font-size: 1.1em !important;
    line-height: 1.4em !important;

.wp_syntax td.code {
    background-image: none;
    background-color: none;


The file is hosted over on GitHub.


If you find the file helpful then please let me know in the comments below. If you’re able to help to improve the file (e.g. by adding support for &c colours - you’ll need to know a little bit of regex) then make a pull request on the official GitHub repository.