Re: Scaling an image and processing the scaled image (Magick++)
| Newsgroups | gmane.comp.video.image-magick.devel |
|---|---|
| Message-ID | <[email protected]> |
> Here is some code, I run Ubuntu 6.10 and compile with g++ `sdl-config
Your version of ImageMagick is 16-bits per pixel. SDL wants 8-bits per pixel.
We also added an optimization as follows:
for (int row = 0; row < surface->h; row++) {
const PixelPacket *imagepixels = image.getConstPixels(0, row, width, 1);
for(int column = 0; column < surface->w; column++) {
{
color = SDL_MapRGB(surface->format,
imagepixels->red/257,
imagepixels->green/257,
imagepixels->blue/257);
}
*surfacepixels = color;
// Increment pointers.
surfacepixels++;
imagepixels++;
}
Here we only grab a scanline at a time which is more memory efficient than
grabbing the entire image at once.