******************************************************************************* * * * T I C T T U T O R I A L S * * * * Executive Editor: thomas.nussbaumer@gmx.net * * Homepage: http://tict.ticalc.org * * * * --------------------------------------------------------------------------- * * * * SERIES 1 - Basic Techniques * * * * PART I: Handling Uncompressed Images in C-Projects v 1.00 * * * * Release Date: 14/08/2000 * * * ******************************************************************************* =============================================================================== Focus of this Tutorial =============================================================================== This tutorial focuses on handling uncompressed images in C-Projects. It will demonstrate how images can be converted and used within your sourcecode. =============================================================================== Necessary Software =============================================================================== (1) TIGCC Development Environment for Windows9x/NT - Version 0.7 http://www.ticalc.org/pub/win/asm/tigcc.zip (2) ImageStudio 1.1 from Matthew Johnson http://www.acz.org/programs/istudio.zip http://www.ticalc.org/pub/win/graphics/istudio.zip =============================================================================== Steps to Convert an Image into C Code =============================================================================== There are many tools around which can convert images into assembler code, but none of them will support C source code directly. So we have to manually post-process the generated code. It doesn't really matter which program you use to generate the assembler code. I have chosen ImageStudio for my projects due to its preview option of the result and the possibility to generate RLE-compressed sourcecode. Okay. Let's start by starting ImageStudio and load the logo.bmp file which comes with this tutorial. In the Image Pulldown Menu we select Standard Grayscale, because we want to generate a 4-grayscale output. Now play around with the sliders until the results looks good. If you want to see a larger preview of the result, just click on magnifying glass icon right beside the Destination view. If you are pleased with the result, enter the File menu and choose Export. In the export dialog we choose Clipboard and the 68k format. Make sure that the RLE Compressed checkbox is NOT checked for now. After pressing Ok you can start your preferred text editor. I use UltraEdit32 which can be widely configurated and can work in Column-Mode (where you can select columns of a text), too. Open a new textfile and paste the output of ImageStudio from the Clipboard into it. It will look like this: Layer1: dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .... many more lines comes here .... dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 Layer2: dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 .... many more lines comes here .... dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 Now let us do some simple "REPLACE ALL" operation with our texteditor. Replace all "$" with "0x". Then append a comma at the end of all data lines and remove all "dc.b" statements. If you have an editor which can select/delete/copy single columns these tasks can be really fast executed (just within seconds). Your new (manipulated) code should look like this: Layer1: 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, .... many more lines comes here .... 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, Layer2: 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, .... many more lines comes here .... 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, Now we remove the Layer1 and Layer2 lines with C variable statements and surround the data with brackets. Don't forget to remove the comma from the last line of each data block. The result should look like this: unsigned char layer1[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, .... many more lines comes here .... 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; unsigned char layer2[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, .... many more lines comes here .... 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; That's all. We have finished the conversion! If you want to see an example how these variables can be used to display the image, examine the source code. =============================================================================== Notes about the Copyleft =============================================================================== These tutorials may be distributed by any other website for non-commercial use only. The author makes no representations or warranties about the suitability of the software and/or informations, either express or implied. The author shall not be liable for any damages suffered as a result of using or distributing this software.