91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-12
  • 語言: C/C++
  • 標簽: pg????

資源簡介

該程序用于pgm格式的圖像讀取與保存,C++編寫,可直接運行,希望能夠幫助到有需要的人。PGM格式的圖像由頭信息和數據信息構成。

資源截圖

代碼片段和文件信息


#include?
#include?
#include?“pgm.h“

/**********************File?I/O?functions*******************************/
/***********************************************************************/

/*Gets?an?ascii?pgm?image?file?store?as?a?color?pgm.*/
void?getPGMfile?(char?filename[]?PGMImage?*img)
?{
???FILE?*in_file;
???char?ch;
???int?row?col?type;
???int?ch_int;
?
???in_file?=?fopen(filename?“r“);
???if?(in_file?==?NULL)
???{
?????fprintf(stderr?“Error:?Unable?to?open?file?%s\n\n“?filename);
?????exit(8);
???}
?
???printf(“\nReading?image?file:?%s\n“?filename);
???
???/*determine?pgm?image?type?(only?type?three?can?be?used)*/
???ch?=?getc(in_file);
???if(ch?!=?‘P‘)
???{
??????printf(“ERROR(1):?Not?valid?pgm/ppm?file?type\n“);
??????exit(1);
???}
???ch?=?getc(in_file);
???/*convert?the?one?digit?integer?currently?represented?as?a?character?to
?????an?integer(48?==?‘0‘)*/
???type?=?ch?-?48;
???if((type?!=?2)?&&?(type?!=?3)?&&?(type?!=?5)?&&?(type?!=?6))
???{
??????printf(“ERROR(2):?Not?valid?pgm/ppm?file?type\n“);
??????exit(1);
???}
?
???while(getc(in_file)?!=?‘\n‘);?????????????/*?skip?to?end?of?line*/
?
???while?(getc(in_file)?==?‘#‘)??????????????/*?skip?comment?lines?*/
???{
?????while?(getc(in_file)?!=?‘\n‘);??????????/*?skip?to?end?of?comment?line?*/
???}
?
???/*there?seems?to?be?a?difference?between?color?and?b/w.??This?line?is?needed
?????by?b/w?but?doesn‘t?effect?color?reading...*/
???fseek(in_file?-1?SEEK_CUR);?????????????/*?backup?one?character*/
?
???fscanf(in_file“%d“?&((*img).width));
???fscanf(in_file“%d“?&((*img).height));
???fscanf(in_file“%d“?&((*img).maxVal));
?
???printf(“\n?width??=?%d“(*img).width);
???printf(“\n?height?=?%d“(*img).height);
???printf(“\n?maxVal?=?%d“(*img).maxVal);
???printf(“\n“);
??
???if?(((*img).width??>?MAX)?||?((*img).height??>?MAX))
???{
?????printf(“\n\n***ERROR?-?image?too?big?for?current?image?structure***\n\n“);
?????exit(1);
???}
?
???if(type?==?2)?/*uncompressed?ascii?file?(B/W)*/
???{
??????for?(row=(*img).height-1;?row?>=0;?row--)
????????for?(col=0;?col????????{
???????????fscanf(in_file“%d“?&ch_int);
???????????(*img).data[row][col].red?=?ch_int;
???????????(*img).data[row][col].green?=?ch_int;
???????????(*img).data[row][col].blue?=?ch_int;
????????}
???}
???else?if(type?==?3)?/*uncompressed?ascii?file?(color)*/
???{
??????for?(row=(*img).height-1;?row?>=0;?row--)
????????for?(col=0;?col????????{
? ??
? ??fscanf(in_file“%d“?&ch_int);
? ??((*img).data[row][col].red)?=?(unsigned?char)ch_int;
??????
? ??fscanf(in_file“%d“?&ch_int);
? ??((*img).data[row][col].green)?=?(unsigned?char)ch_int;
? ??
? ??fscanf(in_file“%d“?&ch_int);
? ??((*img).data[row][col].blue)?=?(unsigned?char)ch_int;
????????}
???}
???else?if(type?==?5)?/*compressed?file?(B/W)*/
?/*note:?this?type?remains?untested?at?this?time...*/
???{
????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-10-10?14:56??pgm_read_save_c\
?????文件????????5884??2018-10-10?14:55??pgm_read_save_c\pgm.c
?????文件?????????766??2018-10-10?14:55??pgm_read_save_c\pgm.h

評論

共有 條評論