⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maketemplate.cpp

📁 从Bwwvers的个人网站上下载的源码
💻 CPP
字号:
/*  ktracker (c) 2006 Kris Beevers  This file is part of ktracker.  ktracker is free software; you can redistribute it and/or modify it  under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or  (at your option) any later version.  ktracker is distributed in the hope that it will be useful, but  WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  General Public License for more details.  You should have received a copy of the GNU General Public License  along with ktracker; if not, write to the Free Software Foundation,  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA  $Id: maketemplate.cpp,v 1.1.1.1 2006/10/10 20:41:29 beevek Exp $*/#include <stdio.h>#include <inttypes.h>// in pgm.cppextern bool load_ppm(const char *file, uint8_t **grid, uint32_t *w, uint32_t *h);extern bool write_ppm(const char *file, const uint8_t *grid, uint32_t w, uint32_t h);int main(int argc, char **argv){  if(argc < 3) {    printf("Usage: %s input.ppm output.ppm\n", argv[0]);    return 1;  }  uint8_t *in, *out;  uint32_t inw, inh, keep = 0;  if(!load_ppm(argv[1], &in, &inw, &inh)) {    perror("load_ppm()");    return 1;  }  // keep all non-black pixels  out = new uint8_t[inw*inh*3];  for(uint32_t i = 0; i < inw*inh*3; i += 3) {    if(in[i] == 0 && in[i+1] == 0 && in[i+2] == 0)      continue;    out[keep++] = in[i];    out[keep++] = in[i+1];    out[keep++] = in[i+2];  }  if(!write_ppm(argv[2], out, keep/3, 1)) {    perror("write_ppm()");    return 1;  }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -