Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#4789 - 01/03/2000 00:56 Displaying a graphic onscreen
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
I have the code compiled from the developer site for displaying something on the screen, but I'm a bit unfamiliar with the way the display works. I have a 128x32 graphic in Photoshop that I want to display with that program, but I have no clue what format to save the file in. Does that program look for a standard graphic type, or does it need a conversion to something non-standard first?


My empeg site is:http://24.236.3.131/empeg/


Top
#4790 - 01/03/2000 02:33 Re: Displaying a graphic onscreen [Re: drakino]
Jazzwire
addict

Registered: 09/06/1999
Posts: 483
Loc: Guernsey
It needs to be in a strange "raw" format.. The developer site should have more info..
However, I've written a small program (in Delphi, so windows only; sorry) to load a bmp and save it in the correct format.
I'll tidy it up a bit if anyone wants a copy... =)

Jazz
(List 112, S/N 00030, 4 gig blue)
_________________________
Jazz (List 112, Mk2 42 gig #40. Mk1 4 gig #30. Mk3 1.6 16v)

Top
#4791 - 01/03/2000 03:15 Re: Displaying a graphic onscreen [Re: drakino]
kim
member

Registered: 21/07/1999
Posts: 140
Loc: Helsinki, Finland
I have the code compiled from the developer site for displaying something on the screen, but I'm a bit unfamiliar with the way the display works. I have a 128x32 graphic in Photoshop that I want to display with that program, but I have no clue what format to save the file in. Does that program look for a standard graphic type, or does it need a conversion to something non-standard first?

That sample program just blits from stdin to display in display's raw format, which is 4-bits a pixel (little-endian).

I'm using a TGA loader for my own apps, but as the TGA loader is heavily dependent on the other stuff I've done, it's not easy to copy&paste it here. So I took the same sample from dev-site and added the 8-bit -> 4-bit conversion to it, so that you can load raw files with the attached example. But if you consider programming anything in larger scale, I would suggest to write a proper image reader.

So, to get your image to the display:
1) compile the attached program
2) make your image 128x32 sized (image can use all 256 grayscales)
3) after your image is ready, go to Image/Mode/Grayscale in Photoshop
4) go to File/Save As, choose the .RAW format
5) use the default options, header being 0 sized
6) transfer the image to empeg (file size should be 4096 bytes)
7) run "blitraw < pic.raw" on your empeg, if you named the attached program as blitraw and image as pic.raw

This is the easiest way to get your own image to empeg's display but also the most unsophisticated way to do it. It relies that the raw image file has no palette and that 0 means black and 255 white, on color indices. And it only works with 128x32 images.

PS. Okay, the attachments still does not work.. I'll attach the source code manually to end of this message.

Kim

----------------------------------------------------------
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <unistd.h>
#include <sys/mman.h>

#include <sys/ioctl.h>

#define BLIT(fd) ioctl((fd), _IO('d', 0))
#define DISPLAY(fd, x) ioctl((fd), _IOW('d', 1, int), (x))

int main(int argc, char *argv[])
{
int fd;
caddr_t dmap;
int i = 0, j = 0;
char cBuffer[ 4096 ];
char cLeft = 0, cRight = 0;

fd = open("/dev/display", O_RDWR);
if(fd == -1)
return 1;

dmap = mmap(0, 2048, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (dmap == (caddr_t) -1)
return 2;

if( read( STDIN_FILENO, cBuffer, 4096 ) == -1 )
return -1;

// shuffle bits
for( i = 0; i < 4096; i+=2, ++j )
{
cLeft = cBuffer[ i ] >> 6;
cRight = cBuffer[ i+1 ] >> 6;
dmap[ j ] = (cRight << 4) | cLeft;
}

BLIT(fd);
DISPLAY(fd, 1);

if (munmap(dmap, 2048) == -1 || close(fd) == -1)
return 3;

return 0;
}


Top
#4792 - 01/03/2000 15:32 Re: Displaying a graphic onscreen [Re: kim]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
Thanks for the code for the 8 -> 4 bit conversion, it works wonderfully for what I need. All I am doing at this point is displaying my own startup graphic alongside a startup sound. (I still like the empeg and Tux logo too much to replace it in the kernel).

I'm finding myself rather rusty in real programming unfortunatly. Hopefully I can get better by the time the Mark 2 comes out, and still remember the sudo C programming for PHP3, and remember Javascript correctly :-)


My empeg site is:http://24.236.3.131/empeg/


Top