This program displays an image which is then slowly replaced using a cool transition effect. We do this by creating an array of 0-3999, randomising it and then use this random order to replace the screen bytes with the bytes from another image.
You can download the source using the link below, the actual .app is not included as you will need to specify two image files for the program to use. Once this is done, just run or double click on make.bat to create the pictran.app file.
The Cybiko SDK
Two Cybiko .pic files which are 160x100 (4008 bytes each)
// // Simple picture transition by ssjx (04/08/2006) // #include <cybiko.h> struct module_t main_module; struct FileInput file_input; // As we are loading two images later, it is best to put the loading into a function we can // re-use. If we can open the file, we skip the first 8 bytes and copy the remaining 4000 (which // is the actual raw image) to the area of memory pointed to by the 'dest' variable. void loadpic(char *filename,char *dest){ FileInput_ctor(&file_input); if (FileInput_open( &file_input,filename)){ TRACE("Loading picture: %s",filename); FileInput_seek( &file_input, 8, SEEK_SET ); Input_read( &file_input,dest,4000); }else{ TRACE("Could not open file: %s.",filename); } FileInput_dtor( &file_input, LEAVE_MEMORY); } long main(int argc, char *argv[],bool start){ char *dis; char *pic; int *order; int i; int a,b,c; init_module( &main_module ); dis=DisplayGraphics_get_page_ptr(main_module.m_gfx, 0); pic=(char *)malloc(4000); // This allocated the 4000 integers we will need. In most 'C' programs for other systems, we would // just use a large array (e.g. int order[4000];) but the Cybiko SDK does not like large amounts of memory // being allocated like that, so we use malloc or calloc instead. We must remember to free() these when // we are done though, this gives the memory back to the system. order=(int *)calloc(4000,sizeof(int)); if (pic!=0 && order!=0){ TRACE("Allocated required memory!"); // This fills the order array with the values 0-3999. We will change the order of these values so that when we // display the new image, it appears by a random pattern. for(i=0;i<4000;i++){ order[i]=i; } // This randomises the order array. It picks two values at random and then swaps them. We will read through this // array and use the values to determine which bytes to replace for(i=0;i<4000;i++){ a=random(4000); b=random(4000); c=order[a]; order[a]=order[b]; order[b]=c; } TRACE("Loading images!"); // Using our 'loadpic' function, we load the image to the display memory and then show it. Make sure this image // file is one that is on your Cybiko's flash memory. loadpic("pic1.pic",dis); DisplayGraphics_show(main_module.m_gfx); //This loads our other image into the memory block we allocated earlier. // This also needs to be an image on your Cybiko's flash. loadpic("pic2.pic",pic); // To show the new image, we read through the order array and use the value to replace the pixel blocks. Each // image byte holds the bits for four pixels. We call the show function to update the display after each change. TRACE("Displaying!"); for(i=0;i<4000;i++){ dis[order[i]]=pic[order[i]]; DisplayGraphics_show(main_module.m_gfx); } }else{ TRACE("Could not allocate memory"); } free(pic); free(order); return 0l; }
Updated 20/07/2026