Third Anniversary

Today marks this blog’s third anniversary. To celebrate and take a look back at the year, I have collected a few image highlights.

Multibrot Set
Multibrot Set
Pinhole Photographs MMXVII
Pinhole Photographs MMXVII
Asciify
Asciify
Mandelbrot Set III
Mandelbrot Set III
Rainbowify
Rainbowify
BMP Implementation in C
BMP Implementation in C
Animating the Quantum Drunkard’s Walk
Animating the Quantum Drunkard’s Walk
Christmas MMXVII
Christmas MMXVII
Lyapunov Fractal
Lyapunov Fractal

17500615947440398742637684298448259300459653195179624088723406481656498345927782897306957959023081425157582777952426879442535942327333206022815634243070984075006080698433225695442819778347008.0

BMP Implementation in C — Graphic Primitives

Continuing development of my C bitmap library, I added basic graphic primitives to augment the library’s functionality beyond simply reading and writing bitmaps and manually manipulating individual pixels. Source code can be seen below and also downloaded — bmp.c.
The underlying implementation of the bitmap file format can be seen in my prior post BMP Implementation in C.
Graphic primitives include drawing lines, rectangles, circles, ellipses; rotating, flipping, cropping, resizing and blitting images. A full list of defined graphic primitives can be seen below, together with a short functionality description.

drw
Test image regarding drawing primitives.
/* === DRAWING PRIMITIVES === */
void hline      (image *img, int x0, int x1, int y , int c               ); // draw horizontal line
void vline      (image *img, int x , int y0, int y1, int c               ); // draw vertical line
void line       (image *img, int x0, int y0, int x1, int y1, int c       ); // draw line
void fillrect   (image *img, int x0, int y0, int x1, int y1, int c       ); // draw filled rectangle
void rect       (image *img, int x0, int y0, int x1, int y1, int c       ); // draw rectangle
void fillcircle (image *img, int x , int y , int r , int c               ); // draw filled circle
void circle     (image *img, int x , int y , int r , int t , int c       ); // draw circle (with certain thickness)
void fillellipse(image *img, int x , int y , int rx, int ry, int c       ); // draw filled ellipse
void ellipse    (image *img, int x , int y , int rx, int ry, int t, int c); // draw ellipse (with certain thickness)

/* === TRANSFORMATION PRIMITIVES === */
image *resize   (image *img, int w , int h                                ); // resize an image
image *hflip    (image *img                                               ); // flip horizontally
image *vflip    (image *img                                               ); // flip vertically
image *rrotate  (image *img                                               ); // rotate clockwise
image *lrotate  (image *img                                               ); // rotate counter-clockwise
image *hrotate  (image *img                                               ); // rotate half a revolution
image *crop     (image *img, int x0, int y0, int x1, int y1               ); // crop an image
void   blit     (image *img, image*, int x , int y                        ); // blit an image onto another one
flp
Test image regarding transformation primitives.

Future plans for this library include performance optimizations regarding the ellipse drawing primitives; circle drawing is already optimized as it uses the shape’s symmetry to save computational cost.
Further primitives that may be added include a flood filling functionality as well as the ability to draw irregular polygons.


/* ================================================== *
 *                GENERAL INFORMATION                 *
 * ================================================== *
 * This C program implements functions for handling   *
 * 24-bit images, drawing and parts of the bitmap     *
 * (.bmp) file format. Supported color models include *
 * rgb hsl. There are also functions for mandelbrot   *
 * set fractal rendering.                             *
 *                                                    *
 * Written by Jonathan Frech.                         *
 *                                                    *
 * Edit history:                                      *
 * 23rd, 24th, 27th, 28th, 29th, 30th of June,        *
 * 1st, 2nd, 3rd, 10th, 11th, 13th, 14th, 15th, 16th, *
 * 17th, 18th, 19th, 20th, 25th, 26th, 27th, 29th of  *
 * July 2017, 21st, 22nd, 23rd of March 2018          */

Continue reading