imagemap.cpp revision ab026a45b1869d884ee3f0af690c3879b76425e8
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc/*#########################################################################
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc### G R A Y M A P
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc#########################################################################*/
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxcstatic void gSetPixel(GrayMap *me, int x, int y, unsigned long val)
afdda45f890ee5dfc86e5131a30b11b354d51633Vasumathi Sundaram - Sun Microsystemsstatic void gDestroy(GrayMap *me)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /** methods **/
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini /** fields **/
d62bc4badc1c1f1549c961cfb8b420e650e1272byz for (int i=0 ; i<height ; i++)
6b9e797c2ea518518cb2b57895991d8bdaa167fesowmini/*#########################################################################
6b9e797c2ea518518cb2b57895991d8bdaa167fesowmini### P A C K E D P I X E L M A P
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini#########################################################################*/
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowministatic void ppSetPixel(PackedPixelMap *me, int x, int y, int r, int g, int b)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan *pix = (((unsigned long)r)<<16 & 0xff0000L) |
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan (((unsigned long)b) & 0x0000ffL);
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystemsstatic void ppSetPixelLong(PackedPixelMap *me, int x, int y, unsigned long rgb)
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystems unsigned long *pix = me->rows[y] + x;
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystemsstatic unsigned long ppGetPixel(PackedPixelMap *me, int x, int y)
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystemsstatic int ppWritePPM(PackedPixelMap *me, char *fileName)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan fprintf(f, "P6 %d %d 255\n", me->width, me->height);
d62bc4badc1c1f1549c961cfb8b420e650e1272byzPackedPixelMap *PackedPixelMapCreate(int width, int height)
d62bc4badc1c1f1549c961cfb8b420e650e1272byz PackedPixelMap *me = (PackedPixelMap *)malloc(sizeof(PackedPixelMap));
d62bc4badc1c1f1549c961cfb8b420e650e1272byz /** methods **/
d62bc4badc1c1f1549c961cfb8b420e650e1272byz /** fields **/
d62bc4badc1c1f1549c961cfb8b420e650e1272byz for (int i=0 ; i<height ; i++)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan/*#########################################################################
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan### R G B M A P
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan#########################################################################*/
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanstatic void rSetPixel(RgbMap *me, int x, int y, int r, int g, int b)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanstatic void rSetPixelRGB(RgbMap *me, int x, int y, RGB rgb)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanstatic RGB rGetPixel(RgbMap *me, int x, int y)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhanstatic int rWritePPM(RgbMap *me, char *fileName)
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan fprintf(f, "P6 %d %d 255\n", me->width, me->height);
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini /** methods **/
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan /** fields **/
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan for (int i=0 ; i<height ; i++)
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini/*#########################################################################
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini### I N D E X E D M A P
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini#########################################################################*/
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowministatic void iSetPixel(IndexedMap *me, int x, int y, unsigned int index)
d62bc4badc1c1f1549c961cfb8b420e650e1272byzstatic unsigned int iGetPixel(IndexedMap *me, int x, int y)
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun MicrosystemsIndexedMap *IndexedMapCreate(int width, int height)
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini IndexedMap *me = (IndexedMap *)malloc(sizeof(IndexedMap));
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini /** methods **/
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystems me->getPixel = iGetPixel;
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystems me->getPixelValue = iGetPixelValue;
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystems me->writePPM = iWritePPM;
3bc21d0a9c7b31b1132c254e389a4114c23bcf00Aruna Ramakrishna - Sun Microsystems me->rows = (unsigned int **)
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini for (int i=0 ; i<height ; i++)
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini for (int i=0; i<256 ; i++)
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini/*#########################################################################
4045d94132614e1de2073685a6cdd4fbd86bec33sowmini### E N D O F F I L E
e7801d59e8ceda0cde8ebdfdddd7582ee2ea96efsowmini#########################################################################*/