?? image.hh
字號(hào):
// ==================================================================// Filename: Nimage.h//// Date: 01/11/95// Author: Neil Sumpter// (adpated from D.M.Sergeant)// Description:// General image class, includes data storage, and // display of image. Also uses stuff for live capture//// Modified by ahoward 24 May 2001 to make top bit 'sticky'.// Once set, this bit can only be reset by 'clear'.//// $Id: image.hh,v 1.1 2002/10/27 21:46:13 rtv Exp $// RTV// ==================================================================#ifndef _NIMAGE_CLASS_#define _NIMAGE_CLASS_#include <stdio.h>#include <stdlib.h>#include <string.h>#include "stage_types.hh"class Nimage{public: int width; int height; unsigned char* data; char* win_title; Nimage(); Nimage(unsigned char* array, int w,int h); Nimage(int w,int h); Nimage(Nimage*); inline int get_width(void) {return width;} inline int get_height(void) {return height;} inline int get_size(void) {return width*height;} // get a pixel color by its x,y coordinate inline unsigned char get_pixel(int x, int y) { if (x<0 || x>=width || y<0 || y>=height) return 0; return (char)data[x+(y*width)]; } // get a pixel color by its position in the array inline unsigned char get_pixel( int i) { if( i<0 || i > width*height ) return 0; return (char)data[i]; } inline void set_pixel(int x, int y, unsigned char c) { if (x<0 || x>=width || y<0 || y>=height) return; unsigned char *p = data + x + y * width; *p = (*p & 0x80) | c; } inline unsigned char *get_data(void) {return data;} inline int count_pixels( void ) { int count = 0; for( int p=0; p<width*height; p++ ) if( data[p] ) count++; return count; } // sets the specified region to the color using a fast memset inline void fast_fill_rect( int x, int y, int w, int h, int col ) { for( int a = y; a < y + h; a++ ) memset( data + (a * width + x), col, w ); } void copy_from(Nimage* img); int N_draw_big; void draw_big(void); void draw_small(void); void bgfill( int x, int y, unsigned char col ); void draw_box(int,int,int,int,unsigned char); void draw_circle(int x,int y,int r,unsigned char c); void draw_line(int x1,int y1,int x2,int y2,unsigned char c); // new 1 Dec 2000 - RTV void draw_rect( const Rect t, unsigned char c); //void draw_line_detect(int x1,int y1,int x2,int y2,int c); unsigned char line_detect(int x1,int y1,int x2,int y2); unsigned char rect_detect( const Rect& r); void clear(unsigned char i); void save_image_as_ppm(char*,char*); void save_raw(char* fname); void load_raw(char* fname); bool load_pnm(const char* fname); bool load_pnm_gz(const char* fname); bool load_fig(const char* filename, double ppm, double scale); bool load_fig_polyline(FILE *file, char *line, int size, double scale); ~Nimage(void);};#endif
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -