-
大小: 1.18MB文件类型: .zip金币: 2下载: 0 次发布日期: 2023-11-18
- 语言: C/C++
- 标签: Mandelbrot C语言 并行 OpenMP
资源简介
求曼德勃罗集合C语言串行并行代码,使用OpenMP和MPI来应用并行性。

代码片段和文件信息
#include
#include
#include
#include
#include
struct BMPHeader
{
char bfType[2];
int bfSize; // 文件大小(以字节为单位)
int bfReserved; //设置为0
int bfOffBits; //字节偏移到实际位图数据(= 54)
int biSize; // BITMAPINFOHEADER的大小 字节(= 40)
int biWidth; //图像宽度,以像素为单位
int biHeight; //图像高度,以像素为单位
short biPlanes; /*目标设备中planes的数目(设为1) */
short biBitCount; /* 每个像素的Bits(24) */
int biCompression; //压缩类型(如果没有压缩,则为0)
int biSizeImage; //图像大小,以字节为单位(如果没有压缩则为0)
int biXPelsPerMeter; /* 显示设备的分辨率(像素/米) */
int biYPelsPerMeter; /* 显示设备的分辨率(像素/米) */
int biClrUsed; /* 颜色表中的颜色数(如果为0,则使用biBitCount允许的最大值)*/
int biClrImportant; /* 重要颜色数量。如果为0,则所有颜色都很重要*/
};
int write_bmp(const char *filename int width int height char *rgb)
{
int i j ipos;
int bytesPerLine;
unsigned char *line;
FILE *file;
struct BMPHeader bmph;
/* 每行的长度必须是4个字节的倍数 */
bytesPerLine = (3 * (width + 1) / 4) * 4;
strncpy(bmph.bfType “BM“ 2);
bmph.bfOffBits = 54;
bmph.bfSize = bmph.bfOffBits + bytesPerLine * height;
bmph.bfReserved = 0;
bmph.biSize = 40;
bmph.biWidth = width;
bmph.biHeight = height;
bmph.biPlanes = 1;
bmph.biBitCount = 24;
bmph.biCompression = 0;
bmph.biSizeImage = bytesPerLine * height;
bmph.biXPelsPerMeter = 0;
bmph.biYPelsPerMeter = 0;
bmph.biClrUsed = 0;
bmph.biClrImportant = 0;
file = fopen (filename “wb“);
if (file == NULL) return(0);
fwrite(&bmph.bfType 2 1 file);
fwrite(&bmph.bfSize 4 1 file);
fwrite(&bmph.bfReserved 4 1 file);
fwrite(&bmph.bfOffBits 4 1 file);
fwrite(&bmph.biSize 4 1 file);
fwrite(&bmph.biWidth 4 1 file);
fwrite(&bmph.biHeight 4 1 file);
fwrite(&bmph.biPlanes 2 1 file);
fwrite(&bmph.biBitCount 2 1 file);
fwrite(&bmph.biCompression 4 1 file);
fwrite(&bmph.biSizeImage 4 1 file);
fwrite(&bmph.biXPelsPerMeter 4 1 file);
fwrite(&bmph.biYPelsPerMeter 4 1 file);
fwrite(&bmph.biClrUsed 4 1 file);
fwrite(&bmph.biClrImportant 4 1 file);
line = (unsigned char *) malloc(bytesPerLine);
if (line == NULL)
{
fprintf(stderr “Can‘t allocate memory for BMP file.\n“);
return(0);
}
for (i = height - 1; i >= 0; i--)
{
for (j = 0; j < width; j++)
{
ipos = 3 * (width * i + j);
line[3*j] = rgb[ipos + 2];
line[3*j+1] = rgb[ipos + 1];
line[3*j+2] = rgb[ipos];
}
fwrite(line bytesPerLine 1 file);
}
free(line);
fclose(file);
return(1);
}
void render(char *out int width int height) {
int xy;
for(x=0;x
for(y=0;y //unsigned int xI;
//unsigned int yI;
int index = 3*width*y + x*3;
float x_origin = ((flo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4333 2019-06-06 09:41 曼德勃罗集合串行.cpp
文件 4524 2019-06-06 16:05 曼德勃罗集合并行.cpp
文件 50331702 2019-06-06 16:06 output.bmp
相关资源
- C语言面试笔试题,经典题目
- C语言编程常见问题解答.pdf
- 操作系统c语言模拟文件管理系统844
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- 个人日常财务管理系统(C语言)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- C语言实现的一个内存泄漏检测程序
- DES加密算法C语言实现
- LINUX下命令行界面的C语言细胞游戏
- 用单片机控制蜂鸣器播放旋律程序(
- 学校超市选址问题(数据结构C语言版
评论
共有 条评论