Out of canvas

Log-in or register.

Out of canvas

Published by on May 1st 2012.

In the past few weeks, I was busy working on RW software. I started with the 3D layer, but I got sidetracked very soon. Some old image-related code popped out and demanded to be updated. I am in the middle of the process right now. Consider this post a summary of what could be if everything works out.

Designing a new interface for images

An "interface" in programming world is something that allows splitting a very complex problem into several smaller, more manageable parts. Interfaces are like customs houses. Everything crossing it must fulfill strict criteria. Interfaces also give meanings to application-specific terms and define what interactions are possible.

For example, consider the bevel effect. In order to perform its function, it must be able to access and modify pixels of a raster image. In the last sentence, I have used the terms raster image, pixel, access pixels and modify pixels. All of these must have concrete meaning and are part of an interface definition.

The fall of image size

In the current version, an image is a dumb matrix of pixels with given dimensions. When asked to do so, it provides its content in a requested pixel format. A pixel contains red, green, blue and alpha components with up to 8 bits per channel.

In the next version, image will be a bit smarter and there will be new concepts related to images: background color and content rectangle.

This will allow the editor to be more memory-efficient. While, in the current version, an empty layer takes up as much memory as a layer full of content, in the next version, this will not be the case. An empty layer will consume virtually no memory and a layer with few pixels will consume little memory. The area with the actual pixels will be called content rectangle, while the color out of the rectangle will be filled with a background color.

This change allowed me to greatly lower the importance of the size of the raster layer. In the past, layered image had no explicit size. Its size was the maximum of the layer sizes (this led to some confusion if you dragged and dropped or pasted layers with different dimensions). In the future version, the situation will be reversed. The layered image will have an explicitly set size and the individual layers will all appear to have the same size. This behavior is also perfectly suitable for the 3D layer.

Out of canvas?

An interesting property of the new order is the possibility for the content to lay out of the traditional canvas area. Some or all content may actually be invisible. For example, if a layer larger than the layered image is pasted into the image, only part of the layer will be visible, but all the pasted content will still be there.

Efficiency and consistency gains

Because the image knows, where its content lays, image effects can exploit this property and only process the pixels with the actual content. Application of effects on layers with small content rectangle should be significantly faster in the future.

Another positive side effect will be the simplification of some image operations. Users would not need to specify a color when changing canvas size, because the layers already know their background color. The rotation operation in current version gives the user the option to automatically resize the image to have enough space for all the rotated content. In the future, this option will not be needed - the operation would simply place the extra content out of the canvas and users will find it there later if they change the canvas size.

Ready for the future

While at it, I have made the interface a bit future-proof. There will be no need to change it, if HDR pixel formats or extra color channels are introduced.

The downside

The image interface is a fundamental part of the application and influences a lot of other components. Dll files from old version including all plug-ins will not be compatible with the new version. I would have to maintain two versions of the plug-ins for some time.

Is this the final image interface?

Yes and no. I am satisfied with the way it handles images, but I already have a plan to change how the undo system and the change notification system work within RW apps. This change will influence all the document-specific interfaces. Software is always changing.

Recent comments

user icon Anonymous
What about ICL files?
I wish there were...
Select background
Vista & Win 7 icons