imagemap-gdk.cpp revision 745ed433a9fda800226f8df696c1bf244e45c462
#include <stdlib.h>
#include "imagemap-gdk.h"
/*#########################################################################
## G R A Y M A P
#########################################################################*/
{
if (!buf)
return NULL;
if (!grayMap)
return NULL;
//### Fill in the odd cells with RGB values
int x,y;
int row = 0;
for (y=0 ; y<height ; y++)
{
for (x=0 ; x<width ; x++)
{
int alpha = (int)p[3];
p += n_channels;
}
}
return grayMap;
}
{
if (!grayMap)
return NULL;
if (!pixdata)
return NULL;
int n_channels = 3;
//### Fill in the odd cells with RGB values
int x,y;
int row = 0;
{
{
p += n_channels;
}
}
return buf;
}
/*#########################################################################
## P A C K E D P I X E L M A P
#########################################################################*/
{
if (!buf)
return NULL;
if (!ppMap)
return NULL;
//### Fill in the cells with RGB values
int x,y;
int row = 0;
for (y=0 ; y<height ; y++)
{
for (x=0 ; x<width ; x++)
{
int alpha = (int)p[3];
p += n_channels;
}
}
return ppMap;
}
/*GdkPixbuf *packedPixelMapToGdkPixbuf(PackedPixelMap *ppMap)
{
if (!ppMap)
return NULL;
guchar *pixdata = (guchar *)
malloc(sizeof(guchar) * ppMap->width * ppMap->height * 3);
if (!pixdata)
return NULL;
int n_channels = 3;
int rowstride = ppMap->width * 3;
GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB,
0, 8, ppMap->width, ppMap->height,
rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ??
//### Fill in the cells with RGB values
int x,y;
int row = 0;
for (y=0 ; y<ppMap->height ; y++)
{
guchar *p = pixdata + row;
for (x=0 ; x<ppMap->width ; x++)
{
unsigned long rgb = ppMap->getPixel(ppMap, x, y);
p[0] = (rgb >> 16) & 0xff;
p[1] = (rgb >> 8) & 0xff;
p[2] = (rgb ) & 0xff;
p += n_channels;
}
row += rowstride;
}
return buf;
}
*/
/*#########################################################################
## R G B M A P
#########################################################################*/
{
if (!buf)
return NULL;
if (!rgbMap)
return NULL;
//### Fill in the cells with RGB values
int x,y;
int row = 0;
for (y=0 ; y<height ; y++)
{
for (x=0 ; x<width ; x++)
{
int alpha = (int)p[3];
p += n_channels;
}
}
return rgbMap;
}
/*
GdkPixbuf *rgbMapToGdkPixbuf(RgbMap *rgbMap)
{
if (!rgbMap)
return NULL;
guchar *pixdata = (guchar *)
malloc(sizeof(guchar) * rgbMap->width * rgbMap->height * 3);
if (!pixdata)
return NULL;
int n_channels = 3;
int rowstride = rgbMap->width * 3;
GdkPixbuf *buf = gdk_pixbuf_new_from_data(pixdata, GDK_COLORSPACE_RGB,
0, 8, rgbMap->width, rgbMap->height,
rowstride, NULL, NULL); //first NULL: replace by (GdkPixbufDestroyNotify)g_free ??
//### Fill in the cells with RGB values
int x,y;
int row = 0;
for (y=0 ; y<rgbMap->height ; y++)
{
guchar *p = pixdata + row;
for (x=0 ; x<rgbMap->width ; x++)
{
RGB rgb = rgbMap->getPixel(rgbMap, x, y);
p[0] = rgb.r & 0xff;
p[1] = rgb.g & 0xff;
p[2] = rgb.b & 0xff;
p += n_channels;
}
row += rowstride;
}
return buf;
}
*/
/*#########################################################################
## I N D E X E D M A P
#########################################################################*/
{
if (!iMap)
return NULL;
if (!pixdata)
return NULL;
int n_channels = 3;
//### Fill in the cells with RGB values
int x,y;
int row = 0;
{
{
p[0] = rgb.r & 0xff;
p += n_channels;
}
}
return buf;
}
/*#########################################################################
## E N D O F F I L E
#########################################################################*/