本文整理汇总了C++中PIXEL函数的典型用法代码示例。如果您正苦于以下问题:C++ PIXEL函数的具体用法?C++ PIXEL怎么用?C++ PIXEL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PIXEL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tga_write_row_RLE
static tga_result tga_write_row_RLE(FILE *fp,
const tga_image *src, const uint8_t *row)
{
#define WRITE(src, size) \
if (fwrite(src, size, 1, fp) != 1) return TGAERR_WRITE
uint16_t pos = 0;
uint16_t bpp = src->pixel_depth / 8;
while (pos < src->width)
{
packet_type type = rle_packet_type(row, pos, src->width, bpp);
uint8_t len = rle_packet_len(row, pos, src->width, bpp, type);
uint8_t packet_header;
packet_header = len - 1;
if (type == RLE) packet_header |= BIT(7);
WRITE(&packet_header, 1);
if (type == RLE)
{
WRITE(PIXEL(pos), bpp);
}
else /* type == RAW */
{
WRITE(PIXEL(pos), bpp*len);
}
pos += len;
}
return TGA_NOERR;
#undef WRITE
}
示例2: draw_circle
void draw_circle(uint16 cx, uint16 cy, uint16 r) {
uint16 rSq = r*r;
uint16 x;
uint16 y;
uint16 a;
uint16 b;
uint16 c;
uint16 d;
uint16 ySq;
for (y = 0; y < r; y = y + 1) {
c = cy + y;
d = cy - y;
ySq = y*y;
for (x = 0; x < r; x = x + 1) {
a = cx + x;
b = cx - x;
if (((x*x)+ySq) <= rSq) {
PIXEL(a, c);
PIXEL(a, d);
PIXEL(b, c);
PIXEL(b, d);
}
}
}
}
示例3: debrush_do_draw_string_default_bmf
void debrush_do_draw_string_default_bmf(
DEBrush *brush,
int x, int y, const char *str,
int len, bool needfill,
DEColourGroup *colours)
{
GC gc=brush->d->normal_gc;
if(brush->d->font==NULL)
return;
XSetForeground(ioncore_g.dpy, gc, PIXEL(colours->fg));
if(!needfill){
if(brush->d->font->fontset!=NULL){
#ifdef CF_DE_USE_XUTF8
if(ioncore_g.enc_utf8)
Xutf8DrawString(ioncore_g.dpy, brush->win,
brush->d->font->fontset,
gc, x, y, str, len);
else
#endif
XmbDrawString(ioncore_g.dpy, brush->win,
brush->d->font->fontset,
gc, x, y, str, len);
}else if(brush->d->font->fontstruct!=NULL){
if(ioncore_g.enc_utf8){
XChar2b *str16; int len16=0;
toucs(str, len, &str16, &len16);
XDrawString16(ioncore_g.dpy, brush->win, gc, x, y, str16, len16);
free(str16);
}else{
XDrawString(ioncore_g.dpy, brush->win, gc, x, y, str, len);
}
}
}else{
XSetBackground(ioncore_g.dpy, gc, PIXEL(colours->bg));
if(brush->d->font->fontset!=NULL){
#ifdef CF_DE_USE_XUTF8
if(ioncore_g.enc_utf8)
Xutf8DrawImageString(ioncore_g.dpy, brush->win,
brush->d->font->fontset,
gc, x, y, str, len);
else
#endif
XmbDrawImageString(ioncore_g.dpy, brush->win,
brush->d->font->fontset,
gc, x, y, str, len);
}else if(brush->d->font->fontstruct!=NULL){
if(ioncore_g.enc_utf8){
XChar2b *str16; int len16=0;
toucs(str, len, &str16, &len16);
XDrawImageString16(ioncore_g.dpy, brush->win, gc, x, y, str16, len16);
free(str16);
}else{
XDrawImageString(ioncore_g.dpy, brush->win, gc, x, y, str, len);
}
}
}
}
示例4: Java_java_awt_Toolkit_imgSetRGBPels
void
Java_java_awt_Toolkit_imgSetRGBPels ( JNIEnv* env, jclass clazz, Image * img,
jint x, jint y, jint w, jint h,
jintArray rgbPels, jint off, jint scan)
{
register int row, col;
COLORREF pix;
jboolean isCopy;
jint *rgbs = env->GetIntArrayElements( rgbPels, &isCopy);
jint *rgb = rgbs + off;
int maxCol = x + w;
int maxRow = y + h;
for ( row = y; row < maxRow; row++) {
for ( col = x; col < maxCol; col++) {
pix = rgb[col + row * scan];
if ( (pix & 0xff000000) == 0xff000000 ) {
PIXEL( img->dc, col, row, pix);
}
else {
if ( !img->mask )
createMaskImage( X, img);
PIXEL( img->dcMask, col, row, 0x00ffffff);
PIXEL( img->dc, col, row, 0);
}
}
}
env->ReleaseIntArrayElements( rgbPels, rgbs, JNI_ABORT);
}
示例5: RedrawCanvasImage
static void RedrawCanvasImage(Canvas *C,
int FromX,
int ToX,
int FromY,
int ToY) {
CanvasExtension *CE=CExt(C);
int SwapRedAndBlue = CE->Image->red_mask != ONLY_RED;
for (int Y=FromY; Y<=ToY; Y++)
for (int X=FromX; X<=ToX; X++)
if (TestImage)
XPutPixel(CE->Image,X,Y,X%(1<<BitPlanes));
else if (BitPlanes==24) {
if(SwapRedAndBlue) {
unsigned p = (CE->Mask)&PIXEL(C,X,Y);
unsigned p1 = (GET_RED(p) << 16) | (GET_GREEN(p) << 8) | GET_BLUE(p);
XPutPixel(CE->Image,X,Y,p1);
} else {
XPutPixel(CE->Image,X,Y,(CE->Mask)&PIXEL(C,X,Y));
}
} else if (BitPlanes==16) {
unsigned p = (CE->Mask)&PIXEL(C,X,Y);
unsigned p_r = GET_RED(p) >> 3;
unsigned p_g = GET_GREEN(p) >> 2;
unsigned p_b = GET_BLUE(p) >> 3;
unsigned short p1 = (p_r << 11) | (p_g << 5) | (p_b);
XPutPixel(CE->Image,X,Y,p1);
} else if (BitPlanes==15) {
示例6: ntsc_to_rgb
/* Convert NTSC composite signal to RGB, where composite signal contains only four
non-zero samples beginning at offset */
static void ntsc_to_rgb( ntsc_to_rgb_t const* ntsc, int offset, short* out )
{
float const* kernel = &ntsc->kernel [ntsc_kernel_size / 2 - offset];
float f0 = ntsc->composite [offset];
float f1 = ntsc->composite [offset + 1];
float f2 = ntsc->composite [offset + 2];
float f3 = ntsc->composite [offset + 3];
int x = 0;
while ( x < composite_size )
{
#define PIXEL( get_y ) \
{\
float i = kernel [ 0] * f0 + kernel [-2] * f2;\
float q = kernel [-1] * f1 + kernel [-3] * f3;\
float y = get_y;\
float r = y + i * ntsc->to_rgb [0] + q * ntsc->to_rgb [1];\
float g = y + i * ntsc->to_rgb [2] + q * ntsc->to_rgb [3];\
float b = y + i * ntsc->to_rgb [4] + q * ntsc->to_rgb [5];\
kernel++;\
out [0] = (int) r;\
out [1] = (int) g;\
out [2] = (int) b;\
out += 3;\
}
PIXEL( i - ntsc->composite [x + 0] )
PIXEL( q - ntsc->composite [x + 1] )
PIXEL( ntsc->composite [x + 2] - i )
PIXEL( ntsc->composite [x + 3] - q )
x += 4;
#undef PIXEL
}
}
示例7: SetColor
void SetColor(byte N,byte R,byte G,byte B)
{
if(N)
XPal[N]=PIXEL(R,G,B);
else
XPal0=PIXEL(R,G,B);
}
示例8: check
/* ------------------------------------------------------------------------- */
static BOOL check(const BYTE* pSrc1, UINT32 src1Step,
const BYTE* pSrc2, UINT32 src2Step,
BYTE* pDst, UINT32 dstStep,
UINT32 width, UINT32 height)
{
UINT32 x, y;
for (y = 0; y < height; ++y)
{
for (x = 0; x < width; ++x)
{
UINT32 s1 = *PIXEL(pSrc1, src1Step, x, y);
UINT32 s2 = *PIXEL(pSrc2, src2Step, x, y);
UINT32 c0 = alpha_add(s1, s2);
UINT32 c1 = *PIXEL(pDst, dstStep, x, y);
if (colordist(c0, c1) > TOLERANCE)
{
printf("alphaComp-general: [%"PRIu32",%"PRIu32"] 0x%08"PRIx32"+0x%08"PRIx32"=0x%08"PRIx32", got 0x%08"PRIx32"\n",
x, y, s1, s2, c0, c1);
return FALSE;
}
}
}
return TRUE;
}
示例9: convert_scr7
void convert_scr7 (image *img) {
image *temp;
int i,j;
histogram hist[256];
temp=(image *) malloc (sizeof (image));
temp->x=img->x;
temp->y=img->y;
temp->buffer=(unsigned char *) malloc (img->x*img->y);
for (i=0; i<256; i++) {
hist[i].value=0;
hist[i].index=i;
}
for (j=0; j<img->y; j++)
for (i=0; i<img->x; i++)
hist[ENCODE(img,i,j)].value++;
qsort (hist,256,sizeof (histogram),sort_histogram);
for (j=0; j<temp->y; j++)
for (i=0; i<temp->x; i++)
PIXEL8(temp,i,j)=
match_color(PIXEL(img,i,j,R),PIXEL(img,i,j,G),PIXEL(img,i,j,B),hist);
custom_blit (temp);
show_pal (0,hist);
}
示例10: _mesh
//********************** MANAGERS **********************
Patch::Patch(BMESHptr mesh) :
_mesh(mesh),
_faces(0),
_creases(nullptr),
_borders(nullptr),
_textures(0),
_cur_tex_i(0),
_non_tex_i(0),
_prev_tex(nullptr),
_pixels(0),
_stamp(0),
_mesh_version(0),
_tri_strips_dirty(1),
_tex_coord_gen(nullptr),
_data(nullptr),
_stencil_id(0),
_sps_height(5),
_sps_min_dist(0.35),
_sps_regularity(20.0),
_sample_spacing(0),
_scale(1.0),
_o(PIXEL(0,0)),
_u_o(PIXEL(1,0)),
_v_o(PIXEL(0,1)),
_dynamic_stamp(UINT_MAX),
_do_dynamic_stuff(true),
_do_lod(true),
_do_rotation(true),
_lod_t(0),
_target_scale(1.0),
_down_lim(0.8),
_up_lim(1.4),
_transition_duration(0.4),
_timed_lod_hi(2.0),
_timed_lod_lo(1.0),
_use_timed_lod_transitions(false),
_transition_has_started(false),
_saw_periodic_sync(false),
_use_direction_vec(false),
_use_weighted_ls(true),
_use_visibility_test(true),
_d2d_samples_valid(false)
{
_textures.set_unique();
//XXX - By default, APPEARs will look white if no
// color is defined, so let's not pollute the
// .jot files with yet more gunk...
//set_color(COLOR::white);
if (_mesh)
_mesh->changed(BMESH::RENDERING_CHANGED);
char tmp[64];
sprintf(tmp, "%d", _mesh->patches().num());
set_name(string("patch-") + tmp);
}
示例11: PIXEL
//соседний контурный пиксель
//ВОЗВРАЩАЕТ: false - если нет соседних точек
inline bool ucv::NEIGHBOR_PIXEL( IplImage* src, //исходное контурное изображение
CvPoint* pt //указатель на исходную точку, сюда же будет записана координата соседней точки
)
{
//здесь должна быть проверка на принадлежность пикселя контуру
if(pt->x==0 || pt->y==0 || pt->x == src->width-1 || pt->y == src->height-1)
{
return false;
}
PIXEL(uchar, src, pt->x, pt->y)[0]=254; //помечаем точку как найденную
//перебираем соседние пиксели
if(PIXEL(uchar, src, pt->x, pt->y+1)[0]==255){ //32
pt->y+=1;
return true;
}
if(PIXEL(uchar, src, pt->x+1, pt->y)[0]==255){ //23
pt->x+=1;
return true;
}
if(PIXEL(uchar, src, pt->x, pt->y-1)[0]==255){ //12
pt->y-=1;
return true;
}
if(PIXEL(uchar, src, pt->x-1, pt->y)[0]==255){ //21
pt->x-=1;
return true;
}
if(PIXEL(uchar, src, pt->x+1, pt->y+1)[0]==255){ //33
pt->x+=1;
pt->y+=1;
return true;
}
if(PIXEL(uchar, src, pt->x+1, pt->y-1)[0]==255){ //13
pt->x+=1;
pt->y-=1;
return true;
}
if(PIXEL(uchar, src, pt->x-1, pt->y+1)[0]==255){ //31
pt->x-=1;
pt->y+=1;
return true;
}
if(PIXEL(uchar, src, pt->x-1, pt->y-1)[0]==255) { //11
pt->x-=1;
pt->y-=1;
return true;
}
return false; //нет соседних пикселей
}
示例12: fread
image *open_pcx (char *name) {
FILE *f;
image *img;
PCXHeader header;
unsigned char *temp,*ptr,b1,b2;
int line_size,line,x;
if ((f=fopen (name,"rb"))==NULL)
return NULL;
fread (&header,sizeof (PCXHeader),1,f);
if (header.Manufacturer!=0xA && header.Version!=0x5 &&
header.Encoding!=0x1 && header.BitsPerPixel!=0x8 )
{
fclose (f);
return NULL;
}
img=(image *) safe_malloc (sizeof (image));
img->x=header.Xmax-header.Xmin+1;
img->y=header.Ymax-header.Ymin+1;
img->buffer=(unsigned char *) safe_malloc (img->x*img->y*3);
line_size=header.NPlanes*header.BytesPerLine;
temp=(unsigned char *) safe_malloc (line_size);
for (line=0; line<img->y; line++) {
ptr=temp;
for (x=0; x<line_size;) {
b1=fgetc (f);
if (b1>0xc0) {
b1-=0xc0;
b2=fgetc (f);
memset (ptr,b2,b1);
ptr+=b1;
x+=b1;
}
else {
*ptr++=b1;
x++;
}
}
for (x=0; x<img->x; x++) {
PIXEL (img,x,line,R)=temp[x];
PIXEL (img,x,line,G)=temp[x+header.BytesPerLine];
PIXEL (img,x,line,B)=temp[x+header.BytesPerLine*2];
}
}
fclose (f);
return img;
}
示例13: lifBlit
//
// lifBlit
// blit one LiF into another
//
void lifBlit(lifheader* out, lifheader* in, sdword left, sdword top)
{
sdword y, x;
for (y = 0; y < in->height; y++)
{
for (x = 0; x < in->width; x++)
{
PIXEL(out->data, left + x, top + y, out->width) = PIXEL(in->data, x, y, in->width);
}
}
}
示例14: _FLT
/** interpolateLin: linear (only x) interpolation function, see interpolate */
void _FLT(interpolateLin)(unsigned char *rv, float x, float y,
unsigned char* img, int width, int height,
unsigned char def)
{
int x_f = myfloor(x);
int x_c = x_f+1;
int y_n = myround(y);
float v1 = PIXEL(img, x_c, y_n, width, height, def);
float v2 = PIXEL(img, x_f, y_n, width, height, def);
float s = v1*(x - x_f) + v2*(x_c - x);
*rv = (unsigned char)s;
}
示例15: Seuillage
void Seuillage(IMAGE *image, IMAGE *imres, int seuil)
{
POINT *point = NULL, *pointv=NULL, *pointvv=NULL; /* point courant et point voisin */
short i,j; /* variables indices ligne et colonne du voisinage */
if(crea_POINT(point) == NULL) /* creation des points */
{
fprintf(stderr,"Erreur d'Allocation Memoire du Point : Median \n");
exit (0);
}
if(crea_POINT(pointv) == NULL)
{
fprintf(stderr,"Erreur d'Allocation Memoire du Point Voisin : Median \n");
exit (0);
}
if(crea_POINT(pointvv) == NULL)
{
fprintf(stderr,"Erreur d'Allocation Memoire du Point Voisin suivant : Median \n");
exit (0);
}
/* --- Initialisation des Bords :
on recopie l'image originale --- */
for(POINT_X(point) = 0; POINT_X(point) < NCOL(image);
POINT_X(point)++)
{
POINT_Y(point) = 0; /* premiere ligne */
PIXEL(imres, point) = PIXEL(image, point);
POINT_Y(point) = NLIG(image) - 1;/* derniere ligne */
PIXEL(imres, point) = PIXEL(image, point);
} /*--- fin recopiage 1er et derniere ligne --- */
for(POINT_Y(point) = 0; POINT_Y(point) < NLIG(image);
POINT_Y(point)++)
{
POINT_X(point) = 0;/* premiere colonne */
PIXEL(imres, point) = PIXEL(image, point);
POINT_X(point) = NCOL(image) - 1;/* derniere colonne */
PIXEL(imres, point) = PIXEL(image, point);
}
for(POINT_Y(point) = 0; POINT_Y(point) < NLIG(image); POINT_Y(point)++)
for(POINT_X(point) = 0; POINT_X(point) < NCOL(image); POINT_X(point)++)
{
PIXEL(imres,point) = PIXEL(image,point) < seuil? (short)0 : (short)255;
}
}