两个资源


第一部分:
//一个有贴图3D的长方体
//鼠标左键旋转 右键平移,滑轮缩放
//加了z轴消隐
#include "graphics.h"
#include <time.h>
#include <math.h>
#include <conio.h>
#include <stdio.h>
#definePI3.1415926536
#define byte unsigned char
int width;//工作区宽
int height;//工作区高
int cent_x,cent_y;//当前位置
IMAGE workmap;//画图空间
double * zmap2d;//屏幕点--z轴比较
char *imgname0="绿鱼.jpg";//长方体的四面:长方形
char *imgname1="红鱼.jpg";//长方体的二面:正方形 高=长方形的宽
int jpgw,jpgh;
double viewZ = 3;// 视点 z 轴坐标
// 定义三维点
struct POINT3D
{
double x;
double y;
double z;
byte r;
byte g;
byte b;
byte a;
COLORREF color;//先计算好颜色
};
struct PointCloud //点云
{
long num; //个数
struct POINT3D * p;//点坐标和颜色
};
struct PointCloud *dianyun0; //点云
struct POINT3D * p3;//指向点云中的点
//声明类,函数————————————————————
struct PointCloud *img2PointC(char *imgname);
void cube_img();
void error(char *s)
{
printf("%s\n",s);
getch();
exit(1);
}
void ZoomImage(IMAGE* P,double ZoomRate)
{//目标图像,水平缩放比,是否高质量算法,垂直缩放比
//不填写垂直缩放参数则默认和水平相等
IMAGE tmp;
IMAGE * Q=&tmp;
tmp=*P;//复制原图像,
int Qwidth=Q->getwidth();
int Qheight=Q->getheight();
//根据缩放比率设定目标图像大小
P->Resize((int)(Qwidth*ZoomRate),(int)(Qheight*ZoomRate));
int Pwidth=P->getwidth();
int Pheight=P->getheight();
//分别对原图像和目标图像获取指针
DWORD* M=GetImageBuffer(P);
DWORD* N=GetImageBuffer(Q);
//选择低质量则按常规方法缩放
{
for(int i=0;i<Pheight;i++)
for(int j=0;j<Pwidth;j++)
//根据目标图像像素点位置逆推算原图像像素点赋值
M[j+i*Pwidth]=N[(int)(j/ZoomRate)+(int)(i/ZoomRate)*Qwidth];
}
}