Пример #1
0
void drawLine(int x1, int y1, int x2, int y2) {
    const int deltaX = abs(x2 - x1);
    const int deltaY = abs(y2 - y1);
    const int signX = x1 < x2 ? 1 : -1;
    const int signY = y1 < y2 ? 1 : -1;
    //
    int error = deltaX - deltaY;
		int error2;
    //
    PutPixel(x2, y2);
    while(x1 != x2 || y1 != y2) {
        PutPixel(x1, y1);
        error2 = error * 2;
        //
        if(error2 > -deltaY) {
            error -= deltaY;
            x1 += signX;
        }
        if(error2 < deltaX) {
            error += deltaX;
            y1 += signY;
        }
    }
 
}
inline void Display_DrawRect_If(uint32_t xs, uint32_t xe, uint32_t ys, uint32_t ye, uint16_t colour)
{
	volatile uint32_t n;

	if((xe < xs) || (ye < ys) ) return;

	n = xe - xs;
	do{
		PutPixel((xe-n),ys,colour);
	} while (n--);

	n = xe - xs;
	do{
		PutPixel((xe-n),ye,colour);
	} while (n--);

	n = ye - ys;
	do{
		PutPixel(xs,(ye-n),colour);
	} while (n--);

	n = ye - ys;
	do{
		PutPixel(xe,(ye-n),colour);
	} while (n--);
	
}
Пример #3
0
void glider(u8 x,u8 y){
	PutPixel(x+1,y,1,0);
	PutPixel(x+2,y+1,1,0);
	PutPixel(x  ,y+2,1,0);
	PutPixel(x+1,y+2,1,0);
	PutPixel(x+2,y+2,1,0);
}
Пример #4
0
void rPentamino(u8 x,u8 y){

	PutPixel(x+1,y,1,0);
	PutPixel(x+2,y,1,0);
	PutPixel(x  ,y+1,1,0);
	PutPixel(x+1,y+1,1,0);
	PutPixel(x+1,y+2,1,0);
}
Пример #5
0
static void Line(int x1,int y1,int x2,int y2,int ucPixel) /* ucPixel == color */
 {
    int *px,*py,y,a,b,a1,b1,a2,b2,Aincr,
	Bincr,bincr,d,dx,dy,da,db;

    if(x2==x1)  /* Algorytm Bresenhama */
    {
      if(y1>y2) nSwap(&y1,&y2);
      for(y=y1; y<=y2; y++)
	PutPixel(x1,y,ucPixel);
      return;
    }

    dy=y2-y1;
    dx=x2-x1;

    if(ABS(dy)<=ABS(dx))
    {
      b2=y2; b1=y1; a2=x2; a1=x1;
      px=&a; py=&b;
    }
    else
    {
      b2=x2; b1=x1; a2=y2; a1=y1;
      px=&b; py=&a;
    }

    if(a1>a2)
    {
      nSwap(&a1,&a2);
      nSwap(&b1,&b2);
    }

    if(b2>b1)
      bincr=1;
    else
      bincr=-1;

    da=a2-a1; db=ABS(b2-b1);
    d=2*db-da;
    Aincr=2*(db-da);
    Bincr=2*db;

    a=a1; b=b1;
    PutPixel(*px,*py,ucPixel);

    for(a=a1+1; a<=a2; a++)
    {
      if(d>=0)
      {
	b+=bincr;
	d+=Aincr;
      }
      else d+=Bincr;
      PutPixel(*px,*py,ucPixel );
    }
 }
Пример #6
0
void Cursor::Show (void) {
  if (x-1>=0 || y-1>=0 || x-1+sizex<320 || y-1+sizey<200)
    GetShape (x-1,y-1,sizex,sizey,buffer);
  PutPixel (x,y+1,15);
  PutPixel (x,y-1,15);
  PutPixel (x+1,y,15);
  PutPixel (x-1,y,15);
  visible=1;
}
inline void Display_DrawLine_If(uint32_t xs, uint32_t xe, uint32_t ys, uint32_t ye, uint16_t colour)
{
	/* Bresenham Algorithm */
	int  wwx,hhy,x,y,n,sx,sy,e;
	uint16_t dx,dy;

	wwx = (int)(xe - xs);
	hhy = (int)(ye - ys);
	dx  = ABS(wwx);
	dy  = ABS(hhy);

	if (wwx > 0) sx = 1; else sx = -1;
	if (hhy > 0) sy = 1; else sy = -1;

	x = xs;
	y = ys;

	if ( dx >= dy )
	{
		e = dx;

		for(n=0; n<=dx; ++n){

			PutPixel(x,y,colour);
			x += sx;
			e += 2*dy;

			if (e >= 2*dx){
				e -= 2*dx;
				y += sy;
			}
		}

	}
	else
	{
		e = dy;

		for(n=0; n<=dy; ++n){

			PutPixel(x,y,colour);
			y += sy;
			e += 2*dx;

			if (e>=2*dy){
				e -= 2*dy;
				x += sx;
			}
		}
	}

}
Пример #8
0
void CImage::Hflip()
{
	R_ASSERT(pData);
	for (u32 y=0; y<dwHeight; y++)
	{
		for (u32 x=0; x<dwWidth/2; x++) {
			u32 x2 = dwWidth-x-1;
			u32 t = GetPixel(x,y);
			PutPixel(x,y, GetPixel(x2,y));
			PutPixel(x2,y,t);
		}
	}
}
Пример #9
0
void CImage::Vflip()
{
	R_ASSERT(pData);
	for (u32 y=0; y<dwHeight/2; y++)
	{
		u32 y2 = dwHeight-y-1;
		for (u32 x=0; x<dwWidth; x++) {
			u32 t = GetPixel(x,y);
			PutPixel(x,y, GetPixel(x,y2));
			PutPixel(x,y2,t);
		}
	}
}
Пример #10
0
void CRenderer::Line(Vector p1, Vector p2, int color) {
	int dx, dy, de, err, i, x, y, t;
	int *scr = (int *)screen->pixels;
	int pitch = screen->pitch / 4;

	if(abs(p2.x - p1.x) > abs(p2.y - p1.y)) {
		if(p1.x > p2.x) {
			t = p1.x; p1.x = p2.x; p2.x = t;
			t = p1.y; p1.y = p2.y; p2.y = t;
			}

		t = p2.x - p1.x;
		de = abs(p2.y - p1.y);
		err = t / 2;
		if(p2.y > p1.y) dy = 1;
		else dy = -1;

		y = p1.y;
		for(i = p1.x; i <= p2.x; i++) {
			PutPixel(i,y,color);
			//scr[i + y * pitch] = color;
			err -= de;
			if(err < 0) {
				y += dy;
				err += t;
				}
			}
	} else {
		if(p1.y > p2.y) {
			t = p1.x; p1.x = p2.x; p2.x = t;
			t = p1.y; p1.y = p2.y; p2.y = t;
			}

		t = p2.y - p1.y;
		de = abs(p2.x - p1.x);
		err = t / 2;
		if(p2.x > p1.x) dx = 1;
		else dx = -1;

		x = p1.x;
		for(i = p1.y; i <= p2.y; i++) {
			PutPixel(x,i,color);
			//scr[x + i * pitch] = color;
			err -= de;
			if(err < 0) {
				x += dx;
				err += t;
				}
			}
		}
}
inline void Display_FillCircle_If(uint16_t x_ct,uint16_t y_ct,long diameter, uint16_t colour)
{
	/* Bresenham Midpoint Algorithm */
	long cx, cy, d, dH, dD, n;
	long radius= diameter/2;
	
    d   = 1 - radius;
    dH  = 3;
    dD  = 5 - 2 * radius;
    cy  = radius;

    for (cx = 0; cx <= cy; cx++) {
        if (d < 0) {
            d   += dH;
            dH  += 2;
            dD  += 2;
        }
        else{
            d   += dD;
            dH  += 2;
            dD  += 4;
            --cy;
        }

		/* Between 0-45deg */
		n = 2*cy;
		do{
			PutPixel((cy-n)+ x_ct,cx + y_ct,colour);
		} while (n--);

		/* Between 45-90deg */
		n = 2*cx;
		do{
			PutPixel((cx-n)+ x_ct,cy + y_ct,colour);
		} while (n--);

		/* Between 270-315deg */
		n = 2*cx;
		do{
			PutPixel((cx-n)+ x_ct,-cy + y_ct,colour);
		} while (n--);

		/* Between 315-360deg */
		n = 2*cy;
		do{
			PutPixel((cy-n)+ x_ct,-cx + y_ct,colour);
		} while (n--);

    }
}
Пример #12
0
//the results of a take away equation becomes the blue drawn pixels 
void Pixel_Manager::TakeAwayResult_Drawn(int arg_one , int arg_two, int result_value, int color_value, SDL_Surface *Surface, int square_x_size, int square_y_size) {
		for(int x = 0; x<= square_x_size; x++){
				for(int y = 0; y<= square_y_size; y++) {
					result_value = arg_two - arg_one;
					if(result_value  <= y*x) {
						color_value=0xff0000;
						PutPixel(x,y, color_value, Surface); //std::cout << "red" << std::endl;
					} else {
						color_value=0x0000ff;
						PutPixel(x,y, color_value, Surface); //std::cout << "Blue" << std::endl;	
				    }		
				}
			}
		}
Пример #13
0
int main(){

	unsigned int i;
	unsigned int j;

	ClearVram();
	SetBorderColor(0xBFU);

	/* Fill VRAM */

	for (i = 0U; i < VRAM_SIZE; i++){
		aram[i * 2U     ] = (i     ) & 0xFFU;
		aram[i * 2U + 1U] = (i * 3U) & 0xFFU;
	}

	for (i = 0U; i < VRAM_SIZE; i++){
		vram[i] = (i * 5U) & 0xFFU;
	}

	/* Bitmap modes */

	palette[0] = 0x00U;
	palette[1] = 0xC0U;
	palette[2] = 0x38U;
	palette[3] = 0xF8U;
	palette[4] = 0x07U;
	palette[5] = 0xC7U;
	palette[6] = 0x3FU;
	palette[7] = 0xFFU;

	SetTileTableRow(M40_TILEROW_3BPP, 8U);
	SetTileTableRow(M40_TILEROW_3BPP, 9U);
	SetTileTableRow(M40_TILEROW_3BPP, 10U);
	SetTileTableRow(M40_TILEROW_3BPP, 11U);

	SetTileTableRow(M40_TILEROW_1BPP, 12U);
	SetTileTableRow(M40_TILEROW_1BPP, 13U);
	SetTileTableRow(M40_TILEROW_1BPP, 14U);
	SetTileTableRow(M40_TILEROW_1BPP, 15U);

	for (j = 0U; j < 16U; j ++){
		for (i = 0U; i < 32U; i ++){
			PutPixel(i + (j << 1) + 0U, i + 32U, j);
			PutPixel(i + (j << 1) + 1U, i + 32U, j);
		}
	}

	while(1);

}
inline void Display_DrawCircle_If(uint16_t x_ct,uint16_t y_ct,long diameter, uint16_t colour)
{
	/* Bresenham Midpoint Algorithm */
   long cx, cy, d, dH, dD;

    d   = 1 - radius;
    dH  = 3;
    dD  = 5 - 2 * radius;
    cy  = radius;

    for (cx = 0; cx <= cy; cx++) {
        if (d < 0) {
            d   += dH;
            dH  += 2;
            dD  += 2;
        }
        else{
            d   += dD;
            dH  += 2;
            dD  += 4;
            --cy;
        }

        PutPixel( cy + x_ct,  cx + y_ct, colour);	/* Between   0- 45 */
        PutPixel( cx + x_ct,  cy + y_ct, colour);	/* Between  45- 90 */
        PutPixel(-cx + x_ct,  cy + y_ct, colour);	/* Between  90-135 */
        PutPixel(-cy + x_ct,  cx + y_ct, colour);	/* Between 135-180 */
        PutPixel(-cy + x_ct, -cx + y_ct, colour);	/* Between 180-225 */
        PutPixel(-cx + x_ct, -cy + y_ct, colour);	/* Between 225-270 */
        PutPixel( cx + x_ct, -cy + y_ct, colour);	/* Between 270-315 */
        PutPixel( cy + x_ct, -cx + y_ct, colour);	/* Between 315-360 */
    }
}
Пример #15
0
void lwss(u8 x,u8 y){
	PutPixel(x+1,y,1,0);
	PutPixel(x+4,y,1,0);
	PutPixel(x,y+1,1,0);
	PutPixel(x,y+2,1,0);
	PutPixel(x+4,y+2,1,0);
	PutPixel(x,y+3,1,0);
	PutPixel(x+1,y+3,1,0);
	PutPixel(x+2,y+3,1,0);
	PutPixel(x+3,y+3,1,0);
}
Пример #16
0
void D3DGraphics::DrawLine( int x1,int y1,int x2,int y2,D3DCOLOR c )
{	
	const int dx = x2 - x1;
	const int dy = y2 - y1;

	if( dy == 0 && dx == 0 )
	{
		PutPixel( x1,y1,c );
	}
	else if( abs( dy ) > abs( dx ) )
	{
		if( dy < 0 )
        {
            x1 += x2;
            x2 = x1 - x2;
            x1 -= x2;
            y1 += y2;
            y2 = y1 - y2;
            y1 -= y2;
		}
		const float m = (float)dx / (float)dy;
		const float b = x1 - m*y1;
		for( int y = y1; y <= y2; y = y + 1 )
		{
			int x = (int)(m*y + b + 0.5f);
			PutPixel( x,y,c );
		}
	}
	else
	{
		if( dx < 0 )
        {
            x1 += x2;
            x2 = x1 - x2;
            x1 -= x2;
            y1 += y2;
            y2 = y1 - y2;
            y1 -= y2;
		}
		const float m = (float)dy / (float)dx;
		const float b = y1 - m*x1;
		for( int x = x1; x <= x2; x = x + 1 )
		{
			int y = (int)(m*x + b + 0.5f);
			PutPixel( x,y,c );
		}
	}
}
Пример #17
0
void BIOS::LCD::BufferPush(ui16 clr) {
  PutPixel(m_cpBuffer, clr);
  if (++m_cpBuffer.x >= m_rcBuffer.right) {
    m_cpBuffer.x = m_rcBuffer.left;
    m_cpBuffer.y++;
  }
}
Пример #18
0
void BIOS::LCD::PutImage(const CRect &rcRect, ui16 *pBuffer) {
  int x1 = rcRect.left, x2 = rcRect.right, y1 = rcRect.top, y2 = rcRect.bottom;
  for (int x = x1; x < x2; x++)
    for (int y = y2 - 1; y >= y1; y--) {
      PutPixel(x, y, *pBuffer++);
    }
}
Пример #19
0
static void MakeImageFrame(char *Title,int sizex,int sizey,
			   int RealSignalLen,int RealFreqLen,
                           int opcja,float SplitFactor)
 {
   /* const int SigCentr=RealSignalLen/2;*/
   int i,j;   				        /* Rysowanie "osnowy" rysunku */
   opcja=OFF;
   PutString(sizex/2-4*strlen(Title),12,WHITE,Title);
   Rectangle(0,0,sizex-1,sizey-1,WHITE);	/* Ramka rysunku */
   Rectangle(2,2,sizex-3,sizey-3,WHITE);

   for(i=0 ; i<255 ; i++)			/* Skala barw */
     for(j=0 ; j<20 ; j++)
       PutPixel(10+j,sizey-CENTRY-i,i);
   Rectangle(10,sizey-CENTRY,30,sizey-254-CENTRY,WHITE);
						/* Ramka Mapy */
   Rectangle(70,sizey-CENTRY,70+RealSignalLen,sizey-RealFreqLen-CENTRY,WHITE);
   /* 
      PutStringVertical(35,sizey-CENTRY-10,WHITE,"Frequency [Hz]");
      PutString(70+SigCentr-5*8,sizey-CENTRY+22,WHITE," Time [s] "); 
  

   if(opcja==OFF)  			    
     {
       PutString(100,sizey-CENTRY+30,WHITE,"Signal");
       Rectangle(70,sizey-CENTRY+40,70+RealSignalLen,sizey-CENTRY+140,WHITE);
       PutString(70+SigCentr,sizey-20,WHITE,"Time");    
       PutStringVertical(50,sizey-40,WHITE,"Amplitude");
    }
    */
   MakeTimeFreqScale(RealSignalLen,RealFreqLen,SplitFactor,sizey); 
 }
Пример #20
0
void draw_triangle_optimized(float x0, float y0, float x1, float y1, float x2,
        float y2, byte r, byte g, byte blue) {
    float xmin = floor(lowest(x0, x1, x2));
    float ymin = floor(lowest(y0, y1, y2));
    float xmax = floor(highest(x0, x1, x2));
    float ymax = floor(highest(y0, y1, y2));
    float fa = fij(x0, y0, x1, y1, x2, y2);
    float fb = fij(x1, y1, x2, y2, x0, y0);
    float fc = fij(x2, y2, x0, y0, x1, y1);
    float fa_outside = fij(-1, -1, x1, y1, x2, y2) * fa > 0;
    float fb_outside = fij(-1, -1, x2, y2, x0, y0) * fb > 0;
    float fc_outside = fij(-1, -1, x0, y0, x1, y1) * fc > 0;
    for (float y = ymin; y <= ymax; y++) {
        for (float x = xmin; x <= xmax; x++) {
            float a = fij(x, y, x1, y1, x2, y2) / fa;
            float b = fij(x, y, x2, y2, x0, y0) / fb;
            float c = fij(x, y, x0, y0, x1, y1) / fc;
            if (a >= 0 && b >= 0 && c >= 0 &&
                    (a > 0 || fa_outside) && (b > 0 || fb_outside) &&
                    (c > 0 || fc_outside)) {
                PutPixel(x, y, r, g, blue);
            }
        }
    }
}
Пример #21
0
/*static*/ void BIOS::LCD::RoundRect(int x1, int y1, int x2, int y2, unsigned short clr)
{
	for (int x=x1; x<x2; x++)
		for (int y=y1; y<y2; y++)
			if ( !_Round(min(x-x1, x2-x-1), min(y-y1, y2-y-1)) )
				PutPixel(x, y, clr);
}
void PixelUtils::ComplementaryAlphaImageCreation(IplImage *AlphaImage, IplImage *ComplementaryAlphaImage, int n)
{
  int i,j,k;
  float *pixelcourant, *pixelcourant1;
  
  pixelcourant = (float *) malloc(n * sizeof(float));
  pixelcourant1 = (float *) malloc(n * sizeof(float));

  for(i = 0; i < AlphaImage->width; i++)
    for(j = 0; j < AlphaImage->height; j++)
    {
      if(n == 1)
      {
        GetGrayPixel(AlphaImage,i,j,pixelcourant);
        *pixelcourant1 = 1 - *(pixelcourant);
        PutGrayPixel(ComplementaryAlphaImage,i,j,*pixelcourant1);
      }

      if(n == 3)
      {
        GetPixel(AlphaImage,i,j,pixelcourant);
        for(k = 0; k < 3; k++)
        {
          *pixelcourant1 = 1.0 - *(pixelcourant);
          *(pixelcourant1+1) = 1.0 - *(pixelcourant+1);
          *(pixelcourant1+2) = 1.0 - *(pixelcourant+2);
        }
        PutPixel(ComplementaryAlphaImage,i,j,pixelcourant1);
      }
    }

    free(pixelcourant);
    free(pixelcourant1);
}
Пример #23
0
static void
RenderPoint (float x, float y, float z)
{
	float v[2], local[2], out[2];
	v[0] = x;
	v[1] = z;

	{
		struct viewplane_s *p;
		p = &camera.vplanes[VPLANE_LEFT];
		if (Vec_Dot(v, p->normal) - p->dist < (1 / 32.0))
			return;
		p = &camera.vplanes[VPLANE_RIGHT];
		if (Vec_Dot(v, p->normal) - p->dist < (1 / 32.0))
			return;
	}

	Vec_Subtract (v, camera.pos, local);
	Vec_Transform (camera.xform, local, out);
	if (out[1] > 0.0)
	{
		int sx = camera.center_x - camera.dist * (out[0] / out[1]) + 0.5;
		int sy = camera.center_y - camera.dist * ((y - camera.altitude) / out[1]) + 0.5;
		PutPixel (sx, sy, 0xffff);
	}
}
Пример #24
0
/* Triangle rasterization algorithm with optimizations
*/
void
draw_triangle_optimized(float x0, float y0, float x1, float y1, float x2, float y2,
    byte r, byte g, byte b)
{
	float xmin,xmax,ymin,ymax;
	float f20,f01, f12;
	float alpha,beta,gamma;
	float x,y;
	float off_f12, off_f20, off_f01;
	float x02,x10, x21, y20,y01, y12;
	
	//square around triangle in which all points are looked at
	xmin = min(x0,x1,x2);
	xmax = max(x0,x1,x2);
	ymin = min(y0,y1,y2);
	ymax = max(y0,y1,y2);
	
	f20 = formula(x2,y2, x0, y0, x1, y1);
	f01 = formula(x0,y0, x1, y1, x2, y2);
	f12 = formula(x1,y1, x2, y2, x0, y0);
	
	x02 = (x0-x2)/f20;
	x10 = (x1-x0)/f01;
	x21 = (x2-x1)/f12;

	y20 = (y2-y0)/f20;
	y01 = (y0-y1)/f01;
	y12 = (y1-y2)/f12;

	// calculations for offscreen point
 	off_f12 = formula(x1,y1, x2, y2, off_x, off_y);
	off_f20 = formula(x2,y2, x0, y0, off_x, off_y);
	off_f01 = formula(x0,y0, x1, y1, off_x, off_y);
	
	beta  = ( (y2 - y0)*xmin+(x0-x2)*ymin+x2*y0-y2*x0 ) / f20;
	gamma =	( (y0 - y1)*xmin+(x1-x0)*ymin+x0*y1-x1*y0 ) / f01;
	alpha = ( (y1 - y2)*xmin+(x2-x1)*ymin+x1*y2-x2*y1 ) / f12;

	
	// Loop through square and check if pixel is in triangle
	for (x = xmin; x < xmax; ++x)
	{	
		for (y = ymin; y < ymax; ++y)
		{
			
			// Pixel is in triangle
			if (alpha >= 0 && beta >= 0 && gamma >= 0){
				if((alpha > 0 || (f12*off_f12) > 0) && (beta > 0 || (f20*off_f20) > 0) && (gamma > 0 || (f01*off_f01) > 0)){
					PutPixel(x,y,r,g,b);
				}
			}
			beta  += x02;
			gamma += x10;
			alpha += x21;
		}
		beta  += y20 -(ymax-ymin)*x02;
		gamma += y01 -(ymax-ymin)*x10;
		alpha += y12 -(ymax-ymin)*x21;
	}
}
void BmpDecoderHelper::DoRLEDecode() {
  static const uint8 RLE_ESCAPE = 0;
  static const uint8 RLE_EOL = 0;
  static const uint8 RLE_EOF = 1;
  static const uint8 RLE_DELTA = 2;
  int x = 0;
  int y = height_ - 1;
  while (pos_ < len_ - 1) {
    uint8 cmd = GetByte();
    if (cmd != RLE_ESCAPE) {
      uint8 pixels = GetByte();
      int num = 0;
      uint8 col = pixels;
      while (cmd-- && x < width_) {
        if (bpp_ == 4) {
          if (num & 1) {
            col = pixels & 0xf;
          } else {
            col = pixels >> 4;
          }
        }
        PutPixel(x++, y, col);
        num++;
      }
    } else {
Пример #26
0
int DrawMe(void *dat){
	printf("&");
    for(;;){
    	PutPixel((unsigned char)rand(),(unsigned char)rand(),(unsigned char)rand());
    	render();
    }
}
Пример #27
0
void DrawGridDots(unsigned short spacing)
{
	int i;
	int j;
	unsigned short x;
	unsigned short y;
	unsigned short ndotsx;
	unsigned short ndotsy;

	ndotsx = ((WindowEndX - WindowStartX) / spacing) + 1;
	ndotsy = ((WindowEndY - WindowStartY) / spacing) + 1;

	y = WindowOriginY;

	BeginDraw();
	for (j = 0; j < ndotsy; j++) {
		x = WindowOriginX;

		for (i = 0; i < ndotsx; i++) {
			PutPixel(x, y);
			x += (spacing / Scale);
		}

		y += (spacing / Scale);
	}
	EndDraw();
}
void PixelUtils::cvttoOTHA(IplImage* RGBImage, IplImage* OthaImage)
{
  float* OhtaPixel = (float*) malloc(3*(sizeof(float)));
  float* RGBPixel = (float*) malloc(3*(sizeof(float)));

  for(int i = 0; i < RGBImage->width; i++)
  {
    for(int j = 0;j < RGBImage->height; j++)
    {
      GetPixel(RGBImage, i, j, RGBPixel);

      // I1 = (R + G + B) / 3
      *OhtaPixel = (*(RGBPixel) + (*(RGBPixel + 1)) + (*(RGBPixel + 2))) / 3.0;

      // I2 = (R - B) / 2
      *(OhtaPixel+1) = (*RGBPixel - (*(RGBPixel + 2))) / 2.0;

      // I3 = (2G - R - B) / 4
      *(OhtaPixel+2) = (2 * (*(RGBPixel + 1)) - (*RGBPixel) - (*(RGBPixel + 2))) / 4.0;		
      
      PutPixel(OthaImage, i, j, OhtaPixel);
    }
  }

  free(OhtaPixel);
  free(RGBPixel);
}
Пример #29
0
void DrawGridDotsRelative(unsigned short spacing, unsigned short dx,
	unsigned short dy)
{
	int i;
	int j;
	unsigned short x;
	unsigned short y;
	unsigned short ndotsx;
	unsigned short ndotsy;

	ndotsx = ((WindowEndX - WindowStartX - dx) / spacing) + 1;
	ndotsy = ((WindowEndY - WindowStartY - dy) / spacing) + 1;

	y = WindowOriginY + (dy / Scale);

	BeginDraw();
	for (j = 0; j < ndotsy; j++) {
		x = WindowOriginX + (dx / Scale);

		for (i = 0; i < ndotsx; i++) {
			PutPixel(x, y);
			x += (spacing / Scale);
		}

		y += (spacing / Scale);
	}
	EndDraw();
}
Пример #30
0
/** 
 * @brief Draw a packed binary glyph on an image 
 * @param Image the destination image
 * @param Width, Height the image dimensions
 * @param Glyph the packed binary glyph data
 * @param GlyphWidth, GlyphHeight the glyph dimensions in pixels
 * @param x0, y0 the upper-left corner of the glyph
 * @param Value the grayscale value of the drawn glyph
 */
static void DrawGlyph(unsigned char *Image, int Width, int Height, 
    const unsigned char *Glyph, int GlyphWidth, int GlyphHeight, 
    int x0, int y0, unsigned Value)
{
    unsigned int Packed, Mask;
    int x = 0, y = 0;
    
    if(GlyphWidth)
        while(1)
        {
            /* Unpack each byte in the glyph data into eight pixels */
            for(Mask = 0x80, Packed = *Glyph; Mask; Mask >>= 1)
            {
                if((Packed & Mask))
                    PutPixel(Image, Width, Height, x0 + x, y0 + y, Value);
                
                if(++x >= GlyphWidth)
                {
                    x = 0;
                    
                    if(++y >= GlyphHeight)
                        return;
                }
            }
            
            Glyph++;
        }    
}