Open source, Open mind.

GP2X Wiz SDL Surface Resize

So I got this Gp2x Wiz from ( its a handheld game system that uses Linux for its operating system. Its pretty cool the only thing Is the screen is so small. The SDL Library's that exist on the internet only support 320x240 or 240x320 16 bit. This made it a hassle to port one of my games to the device.

After many crashes I realized that the game I was trying to port's main surface size was 640x480. I had a few choices I could recode all the graphics to use smaller graphics, or I could write a function to 'shrink' the game to the display. I choose the latter and wrote a small function to resize the main surface. I just changed the surface pointer from SDL_SetVideoMode to a new surface created in memory. Then ran the function and had it plot the pixels to the real front surface which was 320x240. It took several segmentation faults before I finally got it working.

I decided to post this code incase anyone else is having the same problem as me. You can download it here. Included is a small demo that uses the surface resizing function. The example uses a little library for fonts called SDL_mxf. Here is the code for the resize function called CopySurface. A few helper functions are also there, CreateSurface to create the offscreen surface, SDL_GetX, SDL_GetY for calculating the positions of the pixels, and InitPoints for storing the values to speed it up a little bit.

- Jared Bruni

SDL_Surface *CreateSurface(size_t w, size_t h)
	SDL_Surface *surface;
	static int rmask, gmask, bmask, amask;
	rmask = 0xF800;
	gmask = 0x07E0;
	bmask = 0x001f;
	amask = 0;
	surface =  SDL_CreateRGBSurface(SDL_SWSURFACE , w, h, 16, rmask, gmask,bmask, amask);
	return surface;

typedef struct _Point {
	int x, y;
} Point;

Point points[640][480];

int SDL_GetX(int w ,int x, int nw) {
     float xp = (float)x * (float)w / (float)nw;
     return (int)xp;

int SDL_GetY(int h, int y, int nh) {
     float yp = (float)y * (float)h / (float)nh;
     return (int)yp;

void InitPoints() {
	int i;
	for(i = 0; i < 640; i++) {
		for(int z = 0; z < 480; z++) {
			points[i][z].x = SDL_GetX(640, i, 320);
			points[i][z].y = SDL_GetY(480, z, 240);

void CopySurface(SDL_Surface *from, SDL_Surface *to) {

	Uint16 *buffer, *buffer_to, color;



	buffer = (Uint16*)from->pixels;
	buffer_to = (Uint16*)to->pixels;
	color = 0;
	for(int x = 0; x < to->w-1; x++) {
		for(int y = 0; y < to->h-1; y++) {
			int cx,cy;
			cx = points[x][y].x;
			cy = points[x][y].y;
			color = *(buffer+(cy*from->pitch/2)+cx);
			*(buffer_to+(y*to->pitch/2)+x) = color;



Like this page


All The software on this site is free and Licensed under the GPL
Please Feel Free to Redistribute (As a Free Download) any of the software on this page.


Loading search widget...

Updates View All

UPDATE @ Wed Jun 14 09:04:55 PDT 2017
Added new version of Acid Cam v2.1.9. New filters/menu design. Download.

UPDATE @ Sun May 14 09:59:54 PDT 2017
Acid Cam for macOS supports 4K resolution so added a sample in 4K on YouTube. Acid Cam v2 Qt is now supported on Raspberry Pi 3/Raspbian.

UPDATE @ Sun Jan 8 10:58:07 PST 2017
Added new version of Acid Cam (v2.1.1) and a few new blog posts. Be sure to check out my GitHub page.

UPDATE @ Thu Dec 15 16:42:56 PST 2016
Updated bug report page with current projects on GitHub. Been working on Acid Cam v2.1.0 and adding new videos to the YouTube channel.

UPDATE @ Sun Jun 19 00:37:30 PDT 2016
Added XChip project to the blog I helped work on with my friend on GitHub.

UPDATE @ Thu Apr 7 11:56:17 PDT 2016
Added new version of Acid Cam for MacOS X.

UPDATE @ Wed Apr 6 08:52:07 PDT 2016
You can now download Acid Cam from Google Play.

UPDATE @ Fri Apr 1 09:59:08 PDT 2016
Finally signed up for twitter you can follow me here.

UPDATE @ Wed Oct 28 10:45:42 PDT 2015
This site now has a BitTorrent Tracker so I can share larger files.

UPDATE @ Sat Sep 12 04:07:24 PDT 2015
Added fixed versions of Super Stoner 420 and Apps collection that fix the issues with the software when running on MacOS X Yosemite.

UPDATE @ Mon Jun 15 15:35:52 PDT 2015
Spent a long time trying to figure out why OpenCV would not compile on Yosemite. Figured it out and statically linked Acid Cam VR 1.1 with the libraries so you no longer need the MacPorts version of OpenCV installed to /opt/local for it work. It should work as long as you have the Oculus Runtime.

UPDATE @ Sat Jun 6 16:11:40 PDT 2015
Added Acid Cam VR for Oculus Rift DK2 to the site with a version for Windows and MacOS X.

UPDATE @ Sun May 17 14:39:14 PDT 2015
It seems the first version of Acid Cam (1.7.7) is incompatible with MacOS X Yosemite for some reason. So if you using Yosemite just pick up version 2 of the program.

UPDATE @ Tue May 12 14:48:53 PDT 2015
Bad news, seems apple deprecated and now dropped support for one of the libraries that SDL 1.2 that I used to compile the majority of the games on this site. So that means I have to recompile and repackage the majority of these programs to get them to work on Yosemite. So the last version supported was 10.9.

UPDATE @ Fri May 8 10:30:56 PDT 2015
Added our first program for the Oculus 2. It requires that you at least have have the Oculus 2 Runtime.

UPDATE @ Wed Feb 11 11:24:23 PST 2015
Added a few new posts to my blog and have been adding new examples to my C++11 Repository

UPDATE @ Sat Dec 13 17:27:03 PST 2014
Added up to date version of Acid Cam 2 for Microsoft Windows.

UPDATE @ Wed Dec 10 11:12:16 PST 2014
The Site has been redesigned and its looking great. Thanks to my friend Daniel Daley who designed the page.

UPDATE @ Thu Oct 9 11:12:06 PDT 2014
Added a image file with the different LostSideDead graphics programs I have created. AlphaFlame HD Launcher needs to be copied to /Applications .

UPDATE @ Thu Oct 2 17:32:12 PDT 2014
Added a new version of Acid Cam v2.0.17 for Ubuntu Linux

UPDATE @ Fri Sep 19 15:19:11 PDT 2014
Made this music video with Alpha Flame HD quite a while ago, check it out!

UPDATE @ Fri Sep 12 14:56:55 PDT 2014
Added a compressed Archive containing the source code for Acid Cam 2 to the site.

UPDATE @ Thu Sep 11 14:51:50 PDT 2014
Added a video demonstration of Acid Cam for iPhone.

UPDATE @ Fri Aug 29 12:20:41 PDT 2014
Updated Acid Cam to version 2.0.16. Added all the filters from AF_Filter and you can now jump to any frame when processing a video.

Follow Me

Facebook Youtube Google Plus