Skip to main content
gamedev.net
🔒 Locked

Bitmap manipulation

Started by cebugdev Aug 24, 2006 at 2:39 AM 1 replies 650+ views
Original Post
cebugdev
cebugdev
hi guys, where can i find source code for manipulating bitmap files? By Manipulation i mean resize, split, merge 2 images. Dont have any time reading theories for now since im near to my deadline and mf freakin boss just gave another task.. See my new task is i have two image and this two image will be merge into 1. example i have two 240x320 image, the output is still 240x320 where the first image takes the place of 0 - 120 and the other images takes the remaining. my idea is to resize the two image into 120x320 and merge. but i dont have any sample source code for it. if you happen to have one, can i ask for it? just the function? pls pls pls :)
stevenmarky
stevenmarky
Skip every other pixel in the bitmaps , or take the average of the two pixels next to each other.
You don't say what language, but the pseudocode could look like this:


Bitmap sourceImage1, sourceImage2, targetImage

for (y=0; y<320; y++)
for (x=0; x<120; x++)
{
targetImage.drawPixel( x, y, ( sourceImage1.pixel(x, y)+sourceImage1.pixel(x+1, y)) / 2);
}

for (y=0; y<320; y++)
for (x=120; x<240; x++)
{
targetImage.drawPixel( x, y, ( sourceImage2.pixel(x-120, y)+sourceImage2.pixel(x-119, y)) / 2);
}


Edit: if your images are not always downsized by exact multiples look up 'image sampling' on google. Bicubic and Bilinear are two that are used often.

[Edited by - stevenmarky on August 24, 2006 5:08:57 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.