Esempio n. 1
0
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
}
Esempio n. 2
0
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);
      }
    }
  }
}
Esempio n. 3
0
File: font.c Progetto: raboof/notion
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);
            }
        }
    }
}
	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);
	}
Esempio n. 5
0
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) {
Esempio n. 6
0
/* 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
	}
}
Esempio n. 7
0
void SetColor(byte N,byte R,byte G,byte B)
{
  if(N)
     XPal[N]=PIXEL(R,G,B);
  else
     XPal0=PIXEL(R,G,B);
}
/* ------------------------------------------------------------------------- */
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;
}
Esempio n. 9
0
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);
}
Esempio n. 10
0
//********************** 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);
}
Esempio n. 11
0
//соседний контурный пиксель
//ВОЗВРАЩАЕТ: 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;	//нет соседних пикселей
}
Esempio n. 12
0
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;
}
Esempio n. 13
0
//
// 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);
        }
    }
}
Esempio n. 14
0
/** 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;
}
Esempio n. 15
0
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;
  }
}
Esempio n. 16
0
void source_init(source_t *source)
{
	transform_identity(&source->transform);
	source->filter = filter_nearest;
	
	source->color = PIXEL(0, 0, 0, 0);
	source->texture = NULL;
	source->texture_tile = false;

	source->alpha = PIXEL(255, 0, 0, 0);
	source->mask = NULL;
	source->mask_tile = false;
}
Esempio n. 17
0
int threshold(TrackingWindow *win, int t)
{
	int i, j, xmax, ymax;

	xmax = win->blob_xmax;
	ymax = win->blob_ymax;

	for(i = win->blob_ymin; i < ymax; i++) {
		for(j = win->blob_xmin; j < xmax; j++) {
			PIXEL(win, i, j) = (PIXEL(win, i, j) < t) ? BACKGROUND : FOREGROUND;
		}
	}

	return 0;
}
Esempio n. 18
0
/** interpolateBiLinBorder: bi-linear interpolation function that also works at the border.
    This is used by many other interpolation methods at and outsize the border, see interpolate */
void _FLT(interpolateBiLinBorder)(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_f = myfloor(y);
    int y_c = y_f+1;
    short v1 = PIXEL(img, x_c, y_c, width, height, def);
    short v2 = PIXEL(img, x_c, y_f, width, height, def);
    short v3 = PIXEL(img, x_f, y_c, width, height, def);
    short v4 = PIXEL(img, x_f, y_f, width, height, def);
    float s  = (v1*(x - x_f)+v3*(x_c - x))*(y - y_f) +
               (v2*(x - x_f) + v4*(x_c - x))*(y_c - y);
    *rv = (unsigned char)s;
}
Esempio n. 19
0
/** interpolateZero: nearest neighbor interpolation function, see interpolate */
void _FLT(interpolateZero)(unsigned char *rv, float x, float y,
                           unsigned char* img, int width, int height, unsigned char def)
{
    int x_n = myround(x);
    int y_n = myround(y);
    *rv = (unsigned char) PIXEL(img, x_n, y_n, width, height, def);
}
Esempio n. 20
0
pixel_t compose_over(pixel_t fg, pixel_t bg)
{
	double mul;
	double mul_cmp;

	double res_a;
	double res_r;
	double res_g;
	double res_b;

	if (ALPHA(bg) == 255) {
		res_a = 1;
		mul = ((double) ALPHA(fg)) / 255.0;
		mul_cmp = 1 - mul;
	} else {
		double fg_a = ((double) ALPHA(fg)) / 255.0;
		double bg_a = ((double) ALPHA(bg)) / 255.0;

		res_a = 1 - (1 - fg_a) * (1 - bg_a);
		mul = fg_a / res_a;
		mul_cmp = 1 - mul;
	}

	res_r = mul * ((double) RED(fg)) + mul_cmp * ((double) RED(bg));
	res_g = mul * ((double) GREEN(fg)) + mul_cmp * ((double) GREEN(bg));
	res_b = mul * ((double) BLUE(fg)) + mul_cmp * ((double) BLUE(bg));

	return PIXEL((unsigned) (res_a * 255),
	    (unsigned) res_r, (unsigned) res_g, (unsigned) res_b);
}
Esempio n. 21
0
void RenderTree(fwk::Texture &image, const VTree &tree, const Camera &camera) {
//		dicom.Blit(image, slice);

    #pragma omp parallel for
    for(int y = 0; y < image.height(); y += 1) {
        for(int x = 0; x < image.width(); x += 1) {
            float tx = float(x) / image.width() - 0.5f;
            float ty = float(y) / image.height() - 0.5f;

            Vec3f eye = camera.pos;
            Vec3f target = eye + camera.front + camera.right * tx + camera.up * ty
                           + Vec3f(0.0001f, 0.0001f, 0.00001f);
            Vec3f dir = Normalize(target - eye);

            u16 value = tree.Trace(eye, dir, 2000);
            int color = (value >> 7) * 4;
            color = Min(color, 255);

#define PIXEL(x, y, col) { image(x, y) = {color, color, color}; }

            PIXEL(x, y, color);
//				   	PIXEL(x + 1, y, color);
//				   	PIXEL(x, y + 1, color);
//				   	PIXEL(x + 1, y + 1, color);

#undef PIXEL
        }
    }
}
Esempio n. 22
0
//поиск контуров
void ucv::findContours(	IplImage* src,				//исходное контурное изобрвжение
					 	ContourStorage* contours	//указаетль на хранилеще контуров
					 	)
{
	CvPoint point;	//текущая точка
	ucv::Contour contour;	//текущий контур
	
	//для каждой точки принадлежащей контуру
	for(int x=0; x<src->width; x++){
		for(int y=0; y<src->height; y++){
			if(PIXEL(uchar, src, x, y)[0]==255){	//если нашли начало контура
				
				//начальный размер вектора
				contour.clear();
				//contour.reserve(std::max(src->width, src->height));	
				
				//первая точка контура
				point = cvPoint(x, y);	
				contour.push_back(point);	//set point in vector
				
				//пока не дойдем до конца контура
				while(NEIGHBOR_PIXEL(src, &point)){	//переход на соседний пиксель					
					//set point in vector
					contour.push_back(point);
				}
				
				//если не слишком короткий контур
				if(contour.size()>1){
					//contour.shrink_to_fit();		//сжимаем вектор до минимального значения
					contours->push_back(contour);	//закидываем данный контур в массив контуров
				}
			}
		}
	}
}
Esempio n. 23
0
image *open_pcx (char *name) {
  FILE *f;
  image *img;
  PCXHeader header;
  unsigned char *temp,*ptr,b1,b2;
  int line_size,line,x;

  img=(image *) malloc (sizeof (image));
  f=fopen (name,"rb");
  fread (&header,sizeof (PCXHeader),1,f);
  
  img->x=header.Xmax-header.Xmin+1;
  img->y=header.Ymax-header.Ymin+1;
  img->buffer=(unsigned char *) malloc (img->x*img->y*3);
  
  line_size=header.NPlanes*header.BytesPerLine;
  temp=(unsigned char *) malloc (line_size);
  
  for (line=0; line<img->y; line++) {
    printf (".");
    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];
    }
  }
  
  printf ("\nsize %d x %d\n",img->x,img->y);
  fclose (f);

  return img;
}
Esempio n. 24
0
void lifBlit1(lifheader* out, lifheader* in, sdword left, sdword top)
{
    sdword y, x;

    if (in->teamEffect1 == NULL)
    {
        return;
    }

    for (y = 0; y < in->height; y++)
    {
        for (x = 0; x < in->width; x++)
        {
            PIXEL(out->teamEffect1, left + x, top + y, out->width) = PIXEL(in->teamEffect1, x, y, in->width);
        }
    }
}
Esempio n. 25
0
//
// lifLongBlit
// blit one RGBA LiF into another
//
void lifLongBlit(lifheader* out, lifheader* in, sdword left, sdword top)
{
    sdword y, x;
    color* sp;
    color* dp;

    sp = (color*)in->data;
    dp = (color*)out->data;

    for (y = 0; y < in->height; y++)
    {
        for (x = 0; x < in->width; x++)
        {
            PIXEL(dp, left + x, top + y, out->width) = PIXEL(sp, x, y, in->width);
        }
    }
}
Esempio n. 26
0
bool source_is_fast(source_t *source)
{
	return (source->mask == NULL)
	    && (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0))
	    && (source->texture != NULL)
	    && (source->texture_tile == false)
	    && transform_is_fast(&source->transform);
}
Esempio n. 27
0
static int fde_load_glyph_surface(void *unused, glyph_id_t glyph_id,
    surface_t **out_surface)
{
	surface_t *surface = surface_create(FONT_WIDTH, FONT_SCANLINES, NULL, 0);
	if (!surface)
		return ENOMEM;
	
	for (unsigned int y = 0; y < FONT_SCANLINES; ++y) {
		for (unsigned int x = 0; x < FONT_WIDTH; ++x) {
			pixel_t p = (fb_font[glyph_id][y] & (1 << (7 - x))) ? 
			    PIXEL(255, 0, 0, 0) : PIXEL(0, 0, 0, 0);
			surface_put_pixel(surface, x, y, p);
		}
	}
	
	*out_surface = surface;
	return EOK;
}
Esempio n. 28
0
/*
@description	Returns the normalized alpha color of the pixel wand.
*/
value nMagick_pixel_get_alpha( value pixel )
{
	PixelWand *pix;

	val_check_kind( pixel, k_pixel );

	pix = PIXEL( pixel );

	return alloc_float( PixelGetAlpha( pix ) );
}
Esempio n. 29
0
File: text.c Progetto: jdunn/gba
void drawChar(int row, int col, char ch, u16 color) {
    int r, c;
    for(r = 0; r < 8; ++r) {
	    for(c = 0; c < 6; ++c) {
		    if(fontdata_6x8[r*6 + c + 48*ch]) {
			    PIXEL(row + r, col + c, color);
            }
        }
    }
}
Esempio n. 30
0
int main(int argc, char* argv[])
{
   FILE  *fpout;
   
   BITMAP immagine;
   
   int n = atoi(argv[2]);
   int j,i;
  /* utilizzo:  copia_immagine file_originale.bmp file_copia.bmp */

  if (argc != 3 )
  {
     printf ("servono due argomenti!\n");
     exit (EXIT_FAILURE);
  }

  if ((fpout = fopen (argv[1], "wb")) == NULL)
  {
     printf ("errore di apertura del file copia\n");
     exit (EXIT_FAILURE);
  }
  

   immagine = CreateEmptyBitmap( n, n);

   for(i = 0; i < n; i++)
   {
      for(j = 0; j < n; j++)
      {
         if( (pow((n/2 - 10), 2) <= (pow(i-n/2,2)+pow(j-n/2, 2))) &&
               (pow(n/2, 2) >= (pow(i-n/2,2) + pow(j-n/2, 2))))
            PIXEL (immagine, i, j).red = 255;
         else
            PIXEL (immagine, i, j).blue = 255;
      }
   }
   
   WriteBitmap (immagine, fpout);

   ReleaseBitmapData (&immagine);

   return EXIT_SUCCESS;
}