资源简介
利用C语言实现动画

代码片段和文件信息
#include
#include
#include “CImage.h“
// 取索引图像的像素索引值。pImgSrc为图像指针,xy为像素坐标,返回像素的索引值,返回0表示出错
BYTE GetPixelIndex(const CImage* pImgSrclong xlong y)
{
if ((pImgSrc == NULL)||(pImgSrc->IsIndexed() == false)) return 0;// 图像指针为空或不是索引图像则返回0
if ((x < 0)||(y < 0)||(x >= pImgSrc->GetWidth())||(y >= pImgSrc->GetHeight())) //判断像素座标合法性
return 0;
BYTE* pDst = (BYTE*)pImgSrc->GetPixelAddress(xy);//取像素值地址
if (pImgSrc->GetBPP() == 8){ //索引值用8位表示
return *pDst;
} else {
BYTE pos;
BYTE iDst = *pDst;
if (pImgSrc->GetBPP() == 4){//索引值用4位表示
pos = (BYTE)(4 * (1 - x % 2));
iDst &= (0x0F << pos);
return (BYTE)(iDst >> pos);
} else if (pImgSrc->GetBPP() == 1){//索引值用1位表示(二值图像)
pos = (BYTE)(7 - x % 8);
iDst &= (0x01 << pos);
return (BYTE)(iDst >> pos);
}
}
return 0;
}
// 根据调色板索引值取像素值。pImgSrc为图像指针,idx为索引值,返回RGBQUAD结构的像素值
RGBQUAD GetPaletteColor(const CImage* pImgSrc BYTE idx)
{
RGBQUAD rgb = {0000};
if ((pImgSrc)&&(pImgSrc->IsIndexed())){
int ncolors = pImgSrc->GetMaxColorTableEntries();//取调色板颜色数目
RGBQUAD *prgbColors = new RGBQUAD[ncolors];
pImgSrc->GetColorTable(0ncolorsprgbColors);//取调色板
if (idx < ncolors)
rgb = prgbColors[idx];//得到像素值
delete [] prgbColors;
}
return rgb;
}
//取像素颜色值,对索引图像和非索引图像均适用
RGBQUAD GetPixelColor(const CImage* pImgSrclong xlong y)
{
RGBQUAD rgb={0000};
if ((!pImgSrc)||(x < 0)||(y < 0)||(x >= pImgSrc->GetWidth())||(y >= pImgSrc->GetHeight()))
return rgb;
if (pImgSrc->IsIndexed()){//索引图像
rgb = GetPaletteColor(pImgSrcGetPixelIndex(pImgSrcxy));
} else {//非索引图像
BYTE* iDst = (BYTE*)pImgSrc->GetPixelAddress(xy);
rgb.rgbBlue = *iDst++;
rgb.rgbGreen= *iDst++;
rgb.rgbRed = *iDst++;
if(pImgSrc->GetBPP() > 24)
rgb.rgbReserved = *iDst;
}
return rgb;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-06-22 23:06 课题设计\
文件 2030 2011-06-02 15:52 课题设计\CImage.cpp
文件 410 2011-06-02 15:53 课题设计\CImage.h
文件 1572918 2011-05-05 12:58 课题设计\Day.bmp
目录 0 2011-06-25 13:29 课题设计\Debug\
文件 5934 2011-06-21 21:05 课题设计\Debug\BuildLog.htm
文件 106459 2011-06-17 16:08 课题设计\Debug\CImage.obj
文件 1572918 2011-05-05 12:58 课题设计\Debug\Day.bmp
文件 22673 2011-06-17 15:22 课题设计\Debug\haiwangxing.jpg
文件 25787 2011-06-17 15:48 课题设计\Debug\huoxing.jpg
文件 26213 2011-06-17 15:49 课题设计\Debug\jinxing.jpg
文件 65 2011-06-21 21:05 课题设计\Debug\mt.dep
文件 29555 2011-06-17 15:50 课题设计\Debug\muxing.jpg
文件 40610 2011-06-17 15:50 课题设计\Debug\shuixing.jpg
文件 3036054 2011-05-07 23:03 课题设计\Debug\Stars.bmp
文件 295794 2011-05-07 10:35 课题设计\Debug\Sun.bmp
文件 17720 2011-06-17 15:51 课题设计\Debug\tianwangxing.jpg
文件 23965 2011-06-17 15:53 课题设计\Debug\tuxing.jpg
文件 879616 2011-06-21 21:05 课题设计\Debug\vc90.idb
文件 618496 2011-06-21 21:05 课题设计\Debug\vc90.pdb
文件 118272 2011-06-21 21:05 课题设计\Debug\课题设计.exe
文件 663 2011-06-17 16:08 课题设计\Debug\课题设计.exe.em
文件 728 2011-06-17 16:08 课题设计\Debug\课题设计.exe.em
文件 621 2011-06-21 21:05 课题设计\Debug\课题设计.exe.intermediate.manifest
文件 847588 2011-06-21 21:05 课题设计\Debug\课题设计.ilk
文件 261877 2011-06-21 21:05 课题设计\Debug\课题设计.obj
文件 1240064 2011-06-21 21:05 课题设计\Debug\课题设计.pdb
文件 22673 2011-06-17 15:22 课题设计\haiwangxing.jpg
文件 25787 2011-06-17 15:48 课题设计\huoxing.jpg
文件 26213 2011-06-17 15:49 课题设计\jinxing.jpg
文件 29555 2011-06-17 15:50 课题设计\muxing.jpg
............此处省略13个文件信息
相关资源
- 安卓c语言开发SDL2+opengles
- 交互式计算机图形学 第六版 OpenGL源代
- VC++基于OpenGL模拟的一个3维空间模型
- opengl绘制汽车.cpp
- opengl实现水流效果sph
- opengl源代码,全是精华!
- OpenGL迷宫山东大学图形学实验三
- opengl的立方体消隐算法
- vc++ opengl代码爆炸
- 我见过最漂亮的CS仿真程序openGL和C+
- 广东某工业大学的openGL课程设计
- 使用OpenGL实现多个小球在密闭空间内
- 利用openGL和C++实现光线跟踪绘图的完
- OpenGl C++太阳系小行星运行系统 可切换
- vc++和OpenGL实现三维地形实时动态显示
- C++实现利用OpenGL实现三维绘图
- 太阳、地球、月亮之间的运动图Open
- MFC 单文档 实现opengl 三维旋转 缩放
- OPENGL的烟花程序(代码)
- MFC+OpenGL三维建模与动画显示
- 基于opengl粒子系统实现喷泉的模拟
- 一个基于openGL的太阳系模型,太阳地
- vc6.0+opengl纯色五角星填充
- vc6.0+opengl动态绘制五角星
- NeHe_OpenGL教程完整版 里面有地址可以
- OpenGL简单——实现立方体贴上不同纹
- MFC实现dem的读取与现实
- VC++ OpenGL三维地形漫游
- OpenGL实现三维地形实时动态显示
- VC++中Opengl实现建筑物虚拟漫游
评论
共有 条评论