Converting PNG to C header files for images

Status
Not open for further replies.

CRxTRDude

Member
I like to build my own APK from the current build using erik's instruction and I want to know how to modify the PNGs like the menu and logo to become C headers, since that's what i saw when I opened the source code of the builds in the images folder. Is it a converter or just in the IDE?

I also want to modify the look of the Android buttons to look like they are less generic buttons and more different button layouts.

The intention is for personal reasons actually, I want to use it for my phone, since I'm happy actually with erik's build of 4074 and I want to test the latest build (4080) on my phone.

I might show my edits for the UI and stuff and if you guys like it, I might contribute it for the code repo.

EDIT: Because the original post is just too selfish. I may so say honestly.
 
I have successfully built, using android tools (SDK & NDK) and the provided bat file, the r4082 build to the Android and it works, now I'll proceed to make a sample image edit  of the touch buttons PNG and see if it works.

EDIT: Doesn't work. Apparently, it reads the h files as the images rather than the PNG.
 
I'm now trying programs here now.
Used the original android button image from the original source.

PNG2CSCC - This apparently spews out the same thing as the original header, a char array, but it has a more bigger size (1152000) versus the original (75498). One thing to note is that it has a lot of configurations. It compiles good (finishes the ndk-build and ant) but it doesn't show up on screen.

ImageConvert - Same thing, much bigger size than the PNG2CSCC one but it doesn't give out the array size.

Are there other programs than these which does a better job or do you need to code them manually?

 
The guy behind Android version, and which could help you, its uTunnels, but he is away for a long time.
You can try PM him, but I doubt he will reply...
 
I'm aware with that actually, I'll be doing researching this deeper.

And actually I did! Apparently, the menus are X PixMaps which I'll just find a converter with, now if only i can image arrays to work ...
 
I found it! I found the solution!  ;D

I searched the internet again, this time adding SDL as my search term then found this link: Using .c/.h images exported with gimp in SDL.

From there, I found the program mbin2h that is compatible with the SDL code that utunnels might have used. I then converted it via command parameter '-c' which converts ASCII letters to hex. I then compared the array size and it's the same.

Original array size: 75498
New array size: 75498

I then used my edited PNG, converted it into header file, made the array pointer to be the same as the original with the array size from the new image, recompiled the android app and lo and behold it works! Finally!

I'll now try to refine the buttons now from thereon in. I might also throw in some modifications and finally post the APK for testing.
 
your apk alongside the image customization will be for standalone games without the need to be in the same default .pak path?
i want one thing like that for my apk games too
congratulations
 
rafhot said:
your apk alongside the image customization will be for standalone games without the need to be in the same default .pak path?
i want one thing like that for my apk games too
congratulations

If you mean to use another folder as the main OpenBOR folder, it's possible to modify the source to point to another folder.

But then again, bundling a pak or your game's data on the APK will take more coding in Java (android's programming language)*, since:
  • You cannot bundle stuff on APKs (unless you want your APK to be too bloated)
  • So, you have to code a way to download your pak/data from an internet server (such as Dropbox on a public folder), but that's beyond me unfortunately, so you have to do with the default apk's location

Conclusion: It's possible but needs more work

BTW, my customization actually is aimed for the default build if that's what you mean.

*You can do that in C but it's impractical for android since we use Android NDK to compile even the OpenBOR main source file, but according to the NDK's documentation, it's not recommended since it 'always increases [the] app complexity'.
 
Status
Not open for further replies.
Back
Top Bottom