ex12bit - Online Linux Manual PageSection : 3
Updated : version 4.4.3
Source : Allegro
Note : Allegro manual

NAMEex12bit − How to fake a 12-bit truecolor mode on an 8-bit card. Allegro game programming library.​

SYNOPSIS#include <allegro.h> Example ex12bit

DESCRIPTIONThis program sets up a 12-bit mode on any 8-bit card, by setting up a 256-colour palette that will fool the eye into grouping two 8-bit pixels into one 12-bit pixel. In order to do this, you make your 256-colour palette with all the combinations of blue and green, assuming green ranges from 0-15 and blue from 0-14. This takes up 16x15=240 colours. This leaves 16 colours to use as red (red ranges from 0-15). Then you put your green/blue in one pixel, and your red in the pixel next to it. The eye gets fooled into thinking it's all one pixel. The example starts setting a normal 256 color mode, and construct a special palette for it. But then comes the trick: you need to write to a set of two adjacent pixels to form a single 12 bit dot. Two eight bit pixels is the same as one 16 bit pixel, so after setting the video mode you need to hack the screen bitmap about, halving the width and changing it to use the 16 bit drawing code. Then, once you have packed a color into the correct format (using the makecol12() function below), any of the normal Allegro drawing functions can be used with this 12 bit display! Things to note: The horizontal width is halved, so you get resolutions like 320x480, 400x600, and 512x768. Because each dot is spread over two actual pixels, the display will be darker than in a normal video mode. Any bitmap data will obviously need converting to the correct 12 bit format: regular 15 or 16 bit images won't display correctly... Although this works like a truecolor mode, it is actually using a 256 color palette, so palette fades are still possible! This code only works in linear screen modes (don't try Mode-X).

SEE ALSOBITMAP(3), END_OF_MAIN(3), MATRIX(3), PALETTE(3), RGB(3), allegro_error(3), allegro_init(3), allegro_message(3), apply_matrix(3), blit(3), circle(3), clear_bitmap(3), clear_keybuf(3), clear_to_color(3), create_bitmap(3), create_bitmap_ex(3), destroy_bitmap(3), ellipsefill(3), fade_out(3), fixcos(3), fixed(3), fixsin(3), fixtoi(3), font(3), get_rotation_matrix(3), getpixel(3), install_keyboard(3), itofix(3), keypressed(3), line(3), makecol(3), masked_blit(3), putpixel(3), rest(3), screen(3), set_clip_rect(3), set_color(3), set_gfx_mode(3), set_palette(3), text_height(3), text_length(3), textout_ex(3), textprintf_ex(3)
0
Johanes Gumabo
Data Size   :   10,124 byte
man-ex12bit.3Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   5 / 183,513
Visitor ID   :     :  
Visitor IP   :   18.222.182.226   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.