Category Archives: Programming

All that has to do with programming languages: news, frameworks, software and tutorials.

Unrelated Framework – Inclusion of ZLib

The Unrelated Framework got support for ziv-lempel compression of data using ZLib. The classes can be compressed in memory, loaded and saved with few rows of code and without limits. For example:

//this works only with resources like images, fonts, sounds, etc...
C_Image *newImage = new C_Image();
newImage->ImportFromFile("test.tga"); //load image from file
newImage->SetFileFormat(UF_FileFormat_Zip(6)); //set a zip file format of 6th level
newImage->SaveToFile("test.img"); //save the zipped resource on file, simple isn't it?

//if you want to load...
newImage->LoadFromFile("test.img"); //the system understands that it was zipped
newImage->SetFileFormat(NULL); //set it NULL if you don't want the zip compression in the future


//this can be used for every kind of object

C_Image *newImage= new C_Image();
newImage->ImportFromFile("test.tga"); //load image from file
C_Object_Zip *objZip = new C_Object_Zip(); //init a zip container
objZip->CompressObject(newImage, 6); //compress the image object
objZip->SaveToFile("test.zob"); //save the zipped object on file
delete newImage;

//if you want to load...
objZip->LoadFromFile("test.zob"); //load the zipped object from file
newImage = (C_Image *)objZip->UncompressObject(); //get the uncompressed object
delete objZip; //delete and free the zip object memory

Gianpaolo Ingegneri
Copyright @ 2010 – All right reserved

Unrelated Framework – Gui and Gui Editor

Finally I completed the GUI of my framework. The best feature is that the Gui can work in two modes: via software or using the OpenGL. It's  very helpful for cross platform compatibility, for video games or other OpenGL purpose.


The Gui is in his first version but it has all the widgets necessary to create professional applications. An interesting feature is that you don't need to program a single row of code to create particular interfaces: with the Gui Editor you can easily project all kind of professional interfaces and load them in your program using few functions. You don't need to code the widgets to make them work properly.  In this way you can save hours of programming.

There is a full list of widgets implemented:

- Button
- Radio button
- CheckBox
- Form
- Frame Window
- FrameBox
- PictureBox
- ScrollBar
- Scroll space
- TextBox
- ComboBox
- Menu
- ListView
- TreeView
- ToolBar
- Image button
- Graphic Api Viewer

Of course the GUI was coded in C++, it's object oriented and it's an integrative part of my Unrelated Framework.

Gianpaolo Ingegneri
Copyright @ 2010 – All right reserved

Ultra Fast Interpolation (via software)

In general, interpolation is a method used to construct a range of values from a set of data points. In digital image computing there are several methods of interpolation to improve the aspect of a transformed image but there is a problem: all of them are too slow to work via software in real time. Infact, we can see fast interpolations in 3d games only because they are performed via hardware by the graphic card (infact in the past it was very difficult to see an interpolation performed in real time).  However, interpolation is usefull  not only for 3d engines but they are an important part of digital image computing so there is a real need to develop a method to make it faster, expecially if you have to work with a large amount of images at the same time. For this reason I have programmed from scratch a set of  optimized algorithms of interpolation that are definite as in the past... but 100 times faster! The only limitation is that they can be used only for scale trasform but numerically they are perfect and faster at the same time.


Moreover, they are useful to generate procedural images in real time, like textures, that can be used in 3d engine or in some paint softwares where you cannot have a 3d card to speed up all the stuff. In this demo you can see the high performaces of different algorithms with images of 16 bit per pixel. To make sure that my interpolation is numerically perfect, I have included also the calculus of the normal map and the bump mapping effect. With biquadratic interpolation you will obtain a still perfect scaled bump map because the normal map calculus is derivative and the biquadratic is a second order reconstruction filter.

There are the performances on my computer:

Zoom 1x (on a 512x512 image)

- Nearest: 400 fps - Bilinear: 270 fps - Biquadratic: 80 fps

Zoom 4x (on a 512x512 image)

- Nearest: 965 fps - Bilinear: 780 fps - Biquadratic: 245 fps

Zoom 16x (on a 512x512 image)

- Nearest: 1405 fps - Bilinear: 1165 fps - Biquadratic: 390 fps

As you can see, the speed of the algorithm is directly proportional to the size of the zoom, however it is very fast also at the minimum size of 1x. This condition is very useful if you have to resize images or to generate textures with a large amount of stretched layers, like perlin noise. CPU: Intel 2 QuadCore 2333 Mhz; RAM: 4 GB DDRII 800Mhz

Gianpaolo Ingegneri
Copyright @ 2010 – All right reserved

Unrelated Framework – Abandoned

The project started from a small framework that I coded for the Amiga 1200. Now the project is much more advanced and it has been developed for many years on pc/windows platforms. In the past it was called Ultimate Framework but there were already several frameworks with the same name and I decided to rename it to Unrelated Framework .

Some features:

- Programmed entirely in C++
- Serialization of Classes
- Cross-platform design
- New image format for digital image processing

- New surface format for computer graphics
- New format for multi channel textures (color, alpha, bump, normals, z-buffer …)
- Algorithms studied to work also via software
- Proprietary format for bitmap fonts
- Powerful procedural generator of textures, static and animated
- Wrapper of OpenGL, OpenCV, OpenEXR, FreeType, etc…
- Flexible GUI studied to work via software and via hardware

This framework is still work in progress and I used it to produce many of the software that you can see in this site.

Gianpaolo Ingegneri
Copyright @ 2011 - All right reserved

Texture Generation V1.0

This time it was a little bit harder. As you can see in this video, my engine can generate in real time very complex textures with the maximum detail at the maximum speed possible.

Each texture is generated in real time at the frame rate showed on the top-left corner of the window (the "generation" label).

- Lumps (512x512, 200 objs, 16 bpp, 345 FPS)
- Blobs (512x512, 16 bpp, 107 FPS)
- Perlin noise (512x512, 8 octaves, 16 bpp, 115 FPS)

Also, the normal map and the bump mapping are calculated in real time. I used 16 bit per pixel to have more precision when I get the normal map (for more informations check my High Static Range video). Precision and speed of this engine are awesome. The final result can loop in all horizontal and vertical directions.

CPU: Intel 2 QuadCore 2333 Mhz; RAM: 4 GB DDRII 800Mhz

©2009 Gianpaolo Ingegneri

High Static Range

This demo shows a new feature about the texture generation engine implemented in my Unrelated Framework. The normalmap used by bump mapping is calculated on the base of an heightmap generated with two different methods: Low Static Range and High Static Range. The enviroment bump mapping shows the difference in quality between the two ranges.

The first range uses only 8 bits per pixel that is too low to represent a continuous surface like the sphere generated in this example and as result we can see many rings on the surface during the light effect. On the contrary, an high range of 16 bits per pixel is perfect to have a light effect on a continuous surface infact we don't have any kind of imperfection. I could use the famous High Dynamic Range to generate the height map, but in my opinion it could be too expensive for the use of memory and the lack of speed (32 bits floating point per pixel, or 16 bits half-float has continuous conversions because cpu doesn't support it).

©2009 Gianpaolo Ingegneri

Get Ascii code from keyboard on windows/c++ (Ita)

Gli eventi windows per la gestione dell'input della tastiera non restituiscono direttamente un codice ascii ma uno molto più intrippato chiamato Virtual Key, studiato per consentire anche la gestione di quei tasti che non fanno parte del testo (come i cursori, il tasto stampa, etc...) o la conversione diretta in formati più avanzati, come l'unicode.

Continue reading

Graphics effects using chunky-to-planar on amiga/c (Ita)

Il cosiddetto modo planar è sempre stato un impedimento per quei programmatori che avevano intenzione di creare effetti grafici tridimensionali sull'Amiga, cosa che invece riusciva facilissima sui pc perchè supportavano nativamente il modo chunky. Esiste infatti una famosa disputa tra chi difendeva le peculiarità del planar (utile per i giochi 2d) e chi invece ne esaltava i difetti (inutile per i giochi 3d), resta comunque una verità indiscutibile: senza chunky non è possibile lavorare direttamente con i pixel, e questa è una gravissima limitazione per chi vuole realizzare effetti grafici di qualsiasi tipo, cioè non ancorati a certe particolari caratteristiche dell'hardware, come rotazioni di immagini, motori in texture mapping, bump mapping, etc.

Fortunatamente esistono delle tecniche di conversione che permettono di minimizzare queste differenze e rendere la vita più facile ai programmatori che tutt'ora, per scopi puramente hobbystici, hanno intenzione di sviluppare qualche piccolo lavoro grafico su questa macchina del passato. Anch'io mi ci sono cimentato con esiti positivi e dato che in rete il materiale scarseggia ho deciso di pubblicare in questo articolo un piccolo progetto che incorpora le tecniche di conversione c2p e p2c più veloci (programmate in assembler) con un esempio di utilizzo all'interno di un listato in c per la visualizzazione degli effetti grafici in tempo reale.

Continue reading

Image scaling with subsampling technique (Ita)

Il sottocampionamento, noto anche come subsampling, è un algoritmo che permette di ridurre il numero di campioni di un segnale digitale oppure di un'immagine senza andare incontro, durante l'inevitabile perdita di informazione, al famoso difetto di aliasing. E' importante ridurre il più possibile questo difetto, perchè l'aliasing potrebbe provocare nei suoni un fastidioso brusio oppure nelle immagini una percezione di forme imprecise o addirittura totalmente alterate.

Continue reading

Fast Fourier Transform with Digital Images (Ita)

All'interno dello zip potete trovare un articolo che tratta il filtraggio delle immagini digitali mediante trasformata FFT 2D (Fast Fourier Transform - Trasformata di Fourier Veloce). Viene fatta un'ampia introduzione sulla teoria che sta alla base di questa tecnica ed analizzate nel dettaglio le diverse strategie implementative dal punto di vista della programmazione in c.

Nel pacchetto sono inclusi i sorgenti completi in c, alcune immagini in formato pgm per fare delle prove e l'eseguibile nel caso abbiate subito voglia di vedere qualcosa di pratico. Oltre alla realizzazione della trasformata di fourier veloce, per poter lavorare in modo completo sullo spettro delle frequenze, sono stati presi in esame tre tipi di filtri diversi: ideale, butterworth e gaussiano. Viene affrontato anche il tema dell'uso dei filtri passabanda come soluzione per correggere eventuali disturbi periodici all'interno di un'immagine.

©2008 Gianpaolo Ingegneri