?? diff.cpp
字號:
/* gridsim2 (c) 2006 Kris Beevers This file is part of gridsim2. gridsim2 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. gridsim2 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 gridsim2; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*/#include <inttypes.h>#include <assert.h>extern bool load_pgm(const char *file, uint8_t **grid, uint32_t *w, uint32_t *h);extern bool write_pgm(const char *file, const uint8_t *grid, uint32_t w, uint32_t h);inline uint8_t myabs(int i) { return i < 0 ? -i : i; }int main(int argc, char **argv){ assert(argc > 2); uint32_t gw, gh, mw, mh; uint8_t *grid, *map, *diff; assert(load_pgm(argv[1], &grid, &gw, &gh)); assert(load_pgm(argv[2], &map, &mw, &mh)); assert(mw == gw && mh == gh); diff = new uint8_t[gw*gh]; for(uint32_t i = 0; i < gw*gh; ++i) // diff[i] = (grid[i] != map[i]) ? 255 : 0; diff[i] = myabs(int(grid[i])-int(map[i])); write_pgm("diff.pgm", diff, gw, gh); return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -