Unoffical empeg BBS

Quick Links: Empeg FAQ | Software | RioCar.Org | Hijack | jEmplode | emphatic
Repairs: Repairs | Addons: Eutronix | Cases

Topic Options
#20432 - 14/10/2000 18:04 Source for logo converter?
stil
stranger

Registered: 01/10/1999
Posts: 31
Loc: Fort Lauderdale, FL

Could someone post the source code that allows you to convert a 128x32 logo image into the format suitable for uploading to the player? All the converter's I've found were for windoze only, and I'm much too lazy to write one myself :)

Thanks!


Top
#20433 - 14/10/2000 23:07 Re: Source for logo converter? [Re: stil]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31244
Loc: Seattle, WA
I won't post C source code since I don't have any, but I will tell you the way the file format works and you can write your own. You're going to have to make some personal decisions about how your code manages the thresholds and you need to know the reasons behind your decisions before you implement.

Okay, here's how it works.

The Empeg display has four shades of color. Each of the VFD pixels is either off or on, and there is a 200hz "time-dither" to produce shades of gray that fall in between "off" and "on". Theoretically, you could have many shades of gray inbetween, but almost all of those shades are very flickery-looking, so the Empeg folks gave us only two shades of gray in addition to black and white. Those shades are 11.1% (pixel is lit 1/9 of the time) and 20% (pixel is lit 1/5 of the time). So you have "off" (black), two shades of gray, and "on" (white), for a total of four colors.

In truth, as I discovered, the two shades of gray don't visibly appear to be 11% and 20% gray, the actual perceived brightness is quite a bit higher than that. So you can't use a straight mathematical conversion from bitmap->logo because there's no hard-and-fast way to determine how the pixels from your monitor translate into empeg screen shades.

In the end, I simply eyeballed the colors and chose arbitrary cutoff points in my editor. Depending on your screen and your eyeballs, you might choose different cutoff points. Here's what my current cutoff points are in my software:

GrayCutoff0 = 30
GrayCutoff1 = 93
GrayCutoff2 = 200

What this means is that all bitmap values between 0 and 30 (on a scale of 0-255) will be black on the empeg. Everything between 31 and 93 gets assigned the empeg's 11% gray level. Everything between 94 and 200 get assigned 20% gray, everything above 201 goes white.

Then, when I show these colors on the Windows screen, they get displayed as these shades:

GrayDisplayValue0 = 0
GrayDisplayValue1 = 91
GrayDisplayValue2 = 115
GrayDisplayValue3 = 255

Eventually I plan to make these values user-configurable, so that folks can adjust the editor to their monitors and eyeballs.

Okay, now that you understand how the cutoffs work, now on to the actual file format.

The file format is as follows:

4 bytes: Ascii characters "empg".
2048 bytes: "Home" image logo data.
2048 bytes: "Car" image logo data.
Total: 4100 bytes.

The way the logo data is arranged is as follows.

Each pixel is represented as a straight number from darkest to lightest: 0 for black, 1 for dark gray, 2 for light gray, 3 for white. The pixels are combined (inefficiently, I might add) so that two pixels are stuffed into the two nibbles of one byte. Like so:

Pixel 1: Lower nibble of first byte.
Pixel 2: Upper nibble of first byte.
Pixel 3: Lower nibble of second byte.
Pixel 4: Upper nibble of second byte.
(etc.)

So the code to translate RGB values into bytes for the file goes something like this (shown in pseudo-code since I only have a VB version which is mostly useless if you plan to code in C):

(Create a fresh file here, and write the
four bytes of the ascii characters "empg" to the file)

For Y = 0 To 31
For X = 0 To 127 Step 2

(Get GrayLevel from source image at (X, Y))
Select Case GrayLevel
Case 0 To Cutoff0
RawNibble = 0
Case (Cutoff0 + 1) To Cutoff1
RawNibble =1
Case (Cutoff1 + 1) To Cutoff2
RawNibble = 2
Case Else
RawNibble = 3
End Select

(Get GrayLevel from source image at (X + 1, Y))
Select Case GrayLevel
Case 0 To Cutoff0
RawNibble2 = 0
Case (Cutoff0 + 1) To Cutoff1
RawNibble2 =1
Case (Cutoff1 + 1) To Cutoff2
RawNibble2 = 2
Case Else
RawNibble2 = 3
End Select

BothNibbles = (RawNibble2 * 16) Or (RawNibble)
// (That's a "binary" OR in VB, I think a "+" would work too?)

(Write the "BothNibbles" byte to the file here)

Next X
Next Y

(Go on to the second image here and do the same
thing a second time.)

Does that help?

___________
Tony Fabris
_________________________
Tony Fabris

Top
#20434 - 15/10/2000 08:36 Re: Source for logo converter? [Re: tfabris]
stil
stranger

Registered: 01/10/1999
Posts: 31
Loc: Fort Lauderdale, FL

Thanks! I've put together some C source based on your comments. This program will take a grayscale .png file and convert it to 4bpp. The cutoff values are user-configurable. Included in the comments is a bash script that will take one (or two) png files, convert them, and upload them to the unit.



Top
#20435 - 15/10/2000 09:05 Re: Source for logo converter? [Re: stil]
EngelenH
enthusiast

Registered: 29/09/2000
Posts: 313
Loc: Belgium/Holland
Cool, I think quite a few people will be happy with this. Me included.

Cheers,
Hans


Mk2 - Blue - 080000431
_________________________
Mk2 This message will selfdestruct in 5 seconds to prevent reproduction.

Top
#20436 - 07/01/2002 19:14 Re: Source for logo converter? [Re: stil]
mcomb
pooh-bah

Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
Thanks! I've put together some C source based on your comments. This program will take a grayscale .png file and convert it to 4bpp. The cutoff values are user-configurable. Included in the comments is a bash script that will take one (or two) png files, convert them, and upload them to the unit.

Now here is a nice old thread! Does anyone have the source for the program linked here (link is broken)? Or is the author still floating around? I want to upload a boot logo to my empeg, but I have to convert it first I guess. Anyway I tried to install Tony's logoeditor on one of my companies test machines (I don't do windows personally) and it wanted some MS DLL. I am not willing to go through DLL hell just to install a logo. Is there any other way to convert a file to the format the empeg wants?

Thanks,
-Mike
_________________________
EmpMenuX - ext3 filesystem - Empeg iTunes integration

Top
#20437 - 07/01/2002 19:29 Re: Source for logo converter? [Re: mcomb]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31244
Loc: Seattle, WA

The microsoft DLL that it wanted was the Visual Basic Run Time Libraries. They are quite common and there's a single-file setup program for them linked at my home page in the same place as the Logo Editor itself. Click on my signature, below, to go to my home page.

Although I respect your choice not to mess with microsoft DLL crap if you don't want to. The only real question you have to ask yourself is, which is more trouble: Writing your own program to get the job done, or downloading and installing a runtime file to get the job done.

Yes, I know the Microsoft VB runtime libraries are crap. Developing the logo editor in VB allowed me to make it feature-rich (if slow-running) in a short period of time. I know that it could be faster, more efficient, and more easily redistributed if it was written in C/C++ and avoided the need for runtime libraries. However, I was not prepared to invest that amount of effort for a quick utility.

If anyone wants to rewrite the logo editor in C, the pseudo-code at the top of this thread contains all the information you need to properly format the file for feeding to the "download.c" code, so be my guest.
_________________________
Tony Fabris

Top
#20438 - 07/01/2002 21:41 Re: Source for logo converter? [Re: tfabris]
mcomb
pooh-bah

Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
Hey Tony. I was actually trying to really hard not to offend with my original post. Maybe I should have tried harder. I am sure you logo editor is a great piece of software, and I know lots of people here are very pleased with it. Since I don't have anything running windows and I am not going to install it on something just to load a logo on my stereo I tried to use one of my offices testing machines which I guess did not have anything installed that would have installed that DLL. For me, it really would be less work to write my own converter (or preferably dig up one somebody has already written) than spend half a day reloading windows on a computer that is not mine if that DLL screws up something. I appreciate the fact that your logoeditor does not have an installer, if it did I never would have touched it in the first place. What it boils down to is I am not going to run an unknown MS installer on a computer that is not mine just to get that DLL.

Thanks,
-Mike
_________________________
EmpMenuX - ext3 filesystem - Empeg iTunes integration

Top
#20439 - 07/01/2002 22:15 Re: Source for logo converter? [Re: mcomb]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Go here. Download the ZIP file that contains just the DLL file. Place the DLL file in the same directory as Tony's logo editor. Unless there's something weird going on, his program/Windows/the runtime linker should look in the local directory for the DLL as well as the standard system places (good security, huh?), and it should work fine.
_________________________
Bitt Faulk

Top
#20440 - 07/01/2002 22:15 Re: Source for logo converter? [Re: mcomb]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31244
Loc: Seattle, WA
I was actually trying to really hard not to offend with my original post.

Sorry, didn't mean to get defensive. You didn't offend, I just wanted to say why it needed the DLL, then I defended my reasons.

Truth is, the fact that I have to defend my reasons at all, makes me really pissed at the way Microsoft has handled Visual Basic in the last few revisions. Once upon a time, you could write a VB program that worked with a single tiny runtime DLL: "vbrun300". You could even drop vbrun into the directory with your application and it would work. Heck, my first couple shots at the logo editor even did it this way. I only ported it from VB3 to VB6 because there were certain bugs I couldn't correct in that older 16-bit code.

Now VB is a bloated mass of OLE libraries and useless crap that's unnecessary 99 percent of the time. If I had access to Delphi, I'd be all over it.

than spend half a day reloading windows on a computer that is not mine if that DLL screws up something.

One of my assumptions was that by "testing machine" you meant a PC that can be re-formatted whenever the mood strikes you. That's what "testing machine" means where I work. We've set up systems with DriveImage where you simply have to run one batch file, and 60 seconds later, you've got a freshly-installed, brand-spanking new installation of Windows ready to mess it up. The whole purpose of our testing machines is to deliberately allow anything to be installed onto them in an attempt to break them.

I think that's why I didn't understand your reluctance to install a DLL. But now that you've explained it, I understand completeley. I know if it weren't my PC, I wouldn't install any DLLs on it, either.

Back to the original question: Even if that link to the C sources is missing, you should be able to cobble something together pretty quick by looking at my pseudo-code example and the description of the file format.
_________________________
Tony Fabris

Top
#20441 - 07/01/2002 22:20 Re: Source for logo converter? [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31244
Loc: Seattle, WA
I seem to recall that I actually attempted using the msvbvm60.dll file by itself once, when I was first experimenting with VB6.

Although it would work on some systems which already had most of the dependent OLE libraries installed, it would fail on any system with a "bare bones" Win95 installation, and that's my lowest-common-denominator reference platform. So I resigned myself to linking the Microsoft libraries and being done with it.
_________________________
Tony Fabris

Top
#20442 - 07/01/2002 22:24 Re: Source for logo converter? [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I suggested it because it worked for me the other day for something. It might have actually been your editor. I don't remember now. Regardless, it's a quick thing he could try and if it doesn't work, then he hasn't done anything particularly invasive to the machine, and he can easily delete it all. No worse off than before.

Too bad MS didn't think it would be a good idea to go ahead and at least give you the option as a developer to link in the appropriate parts of the library. Or install it as a basic library within Windows.
_________________________
Bitt Faulk

Top
#20443 - 07/01/2002 23:06 Re: Source for logo converter? [Re: tfabris]
mcomb
pooh-bah

Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
One of my assumptions was that by "testing machine" you meant a PC that can be re-formatted whenever the mood strikes you.

Hehe, we do web sites/technology for online promotions so testing machine to us is more like those oddball machine in the corner with six different web browsers and two or three OSs installed on it and as little else as possible. We never bothered imaging them because we figured they would just blow up in a couple of days anyway and we would end up setting them up differently. Now it is months latter and somehow they are still running, but if we had to set them up again from scratch it would take somebody the better part of a day just to figure out where to find IE 3 again, let alone get it to work on an OS made in the last five years :-)

In reality it is probably not that much work, but I am not the person that would be responsible for setting one up again if I screwed it up so I don't want to break it on something that is not work related.

Even if that link to the C sources is missing, you should be able to cobble something together pretty quick by looking at my pseudo-code example and the description of the file format.

Yeah, I am looking at that right now. Well see how far I get.

-Mike
_________________________
EmpMenuX - ext3 filesystem - Empeg iTunes integration

Top
#20444 - 08/01/2002 00:07 Re: Source for logo converter? [Re: mcomb]
sendero
journeyman

Registered: 04/01/2002
Posts: 74
Loc: Seattle, WA
just wanted to chime in on the vbvm issues. I actually worked with VB a ton in v5, 6 and even 7. After moving jobs to a java development team, I'm much more partial to java. If you had the souce code for your app, I would actually be interested in porting it to java. And, though its not quite the same, it'd be an interesting activity to port it to C#. If you would be interested in sharing the source, can you PM me ?
_________________________
Rio Car 30gb
2000 Boxster S, <img src="/ubbthreads/images/graemlins/cool.gif" alt="" />

Top
#20445 - 08/01/2002 00:55 Re: Source for logo converter? [Re: mcomb]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
Loc: Seattle, WA
I poked around my ancient file archives and found it. See the attached file. (I think I intended to use this on the logo site way back. I might still to generate ready made bin files from 2 logos on the site one day...)


Attachments
54580-png2empeg.c (59 downloads)

_________________________
Tom

Top
#20446 - 08/01/2002 01:08 Re: Source for logo converter? [Re: drakino]
mcomb
pooh-bah

Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
I poked around my ancient file archives and found it.

Cool. At this point I am about halfway through writing a bmp -> logo converter in java so I think I am going to just finish it. May come in handy to someone someday. Plus it does not require anything else (looks like this c code needs libpng) so it is a bit more convenient. Hopefully I will have some time tomorrow or wednesday to finish it up.

-Mike
_________________________
EmpMenuX - ext3 filesystem - Empeg iTunes integration

Top
#20447 - 08/01/2002 08:08 Re: Source for logo converter? [Re: mcomb]
mschrag
pooh-bah

Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
Hey Mike -- What do you think about including this as part of JEmplode? Were you considering open-sourcing it at all?

Mike

Top
#20448 - 08/01/2002 08:10 Re: Source for logo converter? [Re: tfabris]
mschrag
pooh-bah

Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
Hey Tony -- By what protocol does the logo get moved onto the Player? Is the logo just a special FID and you can use the normal API, or is there a different process for syncing the logo on? I'm thinking about including more support for controlling the Logo in JEmplode ...

Thanks a lot
Mike

Top
#20449 - 08/01/2002 11:25 Re: Source for logo converter? [Re: mschrag]
andy
carpal tunnel

Registered: 10/06/1999
Posts: 5785
Loc: Wivenhoe, Essex, UK
It gets moved to the player in a completely different manner to FIDs, it happens via the serial port while the player is booting (the same as with a kernel upgrade). The C source for this upload process is available here.
_________________________
Remind me to change my signature to something more interesting someday

Top
#20450 - 08/01/2002 11:31 Re: Source for logo converter? [Re: andy]
mschrag
pooh-bah

Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
Cool -- thanks for the info ...

Mike

Top
#20451 - 08/01/2002 11:56 Re: Source for logo converter? [Re: andy]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31244
Loc: Seattle, WA
And remember that when running under Win32, the source code andy just linked has a small bug that should be corrected before compiling. Please see the corresponding FAQ entry here
_________________________
Tony Fabris

Top
#20452 - 08/01/2002 15:02 Re: Source for logo converter? [Re: mschrag]
mcomb
pooh-bah

Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
Hey Mike -- What do you think about including this as part of JEmplode? Were you considering open-sourcing it at all?

Sure, I will gladly make the source available. I am just writing a command line tool though so you guys would probably want to strip out the useful bits of code and wrap a GUI around it.

-Mike
_________________________
EmpMenuX - ext3 filesystem - Empeg iTunes integration

Top
#20453 - 09/01/2002 23:42 Re: Source for logo converter? [Re: mcomb]
mcomb
pooh-bah

Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
OK, for anyone who is interested here is the java source to a program that will take two 24bit bitmap files and convert them into the empeg boot logo format. To use it compile the file, add it to your CLASSPATH and then run

> java bmpTo4bpp player-type home-logo car-logo output-file

The first parameter should be either 'empeg' or 'rio' and determines if the empeg should boot with the empeg graphic/animation or the rio graphic/animation. The second parameter is the home logo. The third parameter is the car logo. The fourth parameter is the output file to create.

All bitmaps must be 24bit, uncompressed, grayscale images. This program will warn you if you try to feed it something else. You can convert other types of images using PhotoShop/Gimp/GraphicConverter/etc. Some software claims 24bit images are really 32bit so try both.

The output file that this creates still needs to be copied to the empeg with download.c from the empeg website. The most excelent FAQ has some info on this process.

-Mike
_________________________
EmpMenuX - ext3 filesystem - Empeg iTunes integration

Top
#20454 - 09/01/2002 23:44 Re: Source for logo converter? [Re: mcomb]
mcomb
pooh-bah

Registered: 31/08/1999
Posts: 1649
Loc: San Carlos, CA
Ohh, and I forgot to thank Tony for the pseudocode above that was extremely helpful in writing this.

Thanks,
-Mike
_________________________
EmpMenuX - ext3 filesystem - Empeg iTunes integration

Top