⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpcdrv.c

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 C
📖 第 1 页 / 共 4 页
字号:
    		m++;
			if( m == ppii->width )
			{
				m = 0;
				GetNextLine( &nextLineAd, &nextLineOffset, nextLineAd, nextLineOffset, gc->vram );
				nextPixelPos = nextLineAd;
				nextPixelOffset = nextLineOffset;
			}
    	}
	}
    for( j = 0; j < rByte; j++ )		
	{
		if( buffer[k] & mask[j] )
		{
//			ColorIndex1 = *(IniAdd + m);	zhuli 2002.1.31
			PixelOp( nextPixelPos, nextPixelOffset, ColorIndex, style );
    	}
		else
		{
			if( mode != GPC_TRANSPARENT_STYLE )
//				*(IniAdd + m) = BkColorIndex;
				PixelOp( nextPixelPos, nextPixelOffset, BkColorIndex, style );
		}
		GetNextPixelPosition( &nextPixelPos, &nextPixelOffset, nextPixelPos, nextPixelOffset );
    	m++;
		if( m == ppii->width )
		{
			m = 0;
//		    IniAdd += gc->width;
			GetNextLine( &nextLineAd, &nextLineOffset, nextLineAd, nextLineOffset, gc->vram );
			nextPixelPos = nextLineAd;
			nextPixelOffset = nextLineOffset;
		}
    }
//zhuli 2002.1.31    
//	topx = ppii->x;
//	topy = ppii->y;
//	endx = topx + ppii->width - 1;
//	endy = topy + ppii->height - 1;
//	if( gc == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
//		WRITELCD( ppii->x, ppii->x + ppii->width - 1, ppii->y, ppii->y + ppii->height - 1 )//WRITELCD( topx, endx, topy, endy )

    return;
}
/*
typedef struct tagPHYIMAGEINFO
{
    SHORT x;
    SHORT y;
    SHORT width;
    SHORT height;
    BYTE  *buffer;
    BYTE  method;
    WORD ColorIndex;
    WORD BkColorIndex;
} PHYIMAGEINFO, *PPHYIMAGEINFO;
*/

//-------------------------------------------------------------------------
// Function name  :seSetImage()
// 
// Description    :to put a device depent image onto the screen. The image buffer format is device relative.
//	               The raster operation method defines how the color data for the source recangle is 
//	               to be combined with the color data for the destination rectangle to achieve the final color
// 
// Parameters:
//      gc: the point that points the current task's gc
//      x,y: specified the left-up position where the image will be placed
//      width: specified the image width
//		height: specified the image height
//		buffer: the buffer contains the image data
//		style : the style to be use to paint the pixel. consisted of:GPC_REPLACE_STYLE,
//              GPC_AND_STYLE,GPC_OR_STYLE,GPC_XOR_STYLE,GPC_COPY_STYLE,GPC_NOT_STYLE
// 
// No return value
//-------------------------------------------------------------------------
void seSetImage(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height , VRAM *buffer, WORD style )
{	
	PIXEL	*lineAd;
	CHAR	bitOffset;

//	TurnOffLCD();			//Julias 2002/5/7
	GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
	BlockOp( lineAd, bitOffset, buffer->ad, 0, width, height, style, gc->vram, buffer );
}

//-------------------------------------------------------------------------
// Function name  :seGetImage()
// 
// Description    :retrieves a block of screen data as an image into a buffer.
//	                the image buffer format is device relative.
//
// Parameters:
//      gc: the point that points the current task's gc
//      x,y: specified the left-up position where the image will be placed
//      width: specified the image width
//	    height: specified the image height
//   	buffer: the buffer contains the image data
// 
// No return value
//-------------------------------------------------------------------------
void seGetImage(GC *gc, SHORT x, SHORT y, SHORT width , SHORT height , VRAM *buffer)
{
	PIXEL	*lineAd;
	CHAR	bitOffset;

	/*
	x1 = x < (x + width) ? x : (x + width);
	x2 = x < (x + width) ? (x + width): x;
	y1 = y < (y + height) ? y : (y + height);  
	y2 = y < (y + height) ? (y + height) : y;
	*/
//	TurnOffLCD();			//Julias 2002/5/7
	GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
	BlockOp( buffer->ad, 0, lineAd, bitOffset, width, height, GPC_COPY_STYLE, buffer, gc->vram );

}

//-------------------------------------------------------------------------
// Function name  :seEllipse()
// 
// Description    :Draw ellipse's Line in the x0, y0, a0, b0.
//
// Parameters:
//      gc: the point that points the current task's gc
//      x: Position x0 of Ellipse.
//      y: Position y0 of Ellipse.
//      a: Position width of Ellipse.
//      b: Position height of Ellipse.
//      ColorIndex : the color to be use to paint the pixel
//      style : the style to be use to paint the pixel. consisted of:GPC_REPLACE_STYLE,
//              GPC_AND_STYLE,GPC_OR_STYLE,GPC_XOR_STYLE,GPC_COPY_STYLE,GPC_NOT_STYLE
// 
// No return value
//-------------------------------------------------------------------------
void seEllipse (GC *gc, SHORT x, SHORT y, SHORT a, SHORT b, PIXEL ColorIndex, WORD style)
{
//    SHORT topx, topy;
    
    SHORT x0 = 0;
    SHORT y0 = b;

    SHORT a0 = a;
    SHORT b0 = b;

    SHORT asqr = a0 * a0;
    LONG two_asqr = asqr<<1;
    SHORT bsqr = b0 * b0;
    SHORT two_bsqr = bsqr<<1;

    LONG d, dx, dy;
	PIXEL *pixelPos;
	CHAR bitOffset;
    
//	WORD ColorIndex1;   //暂存ColorIndex

    d = bsqr - asqr * b0 + (asqr >> 2);

    dx = 0;
    dy = (LONG)two_asqr * b0;

//    SETPIXEL((SHORT)x, (SHORT)(y + b))	//seSetPixel(x, (SHORT)(y + b));seSetPixel( gc, x, y+b, ColorIndex, style)
//    SETPIXEL((SHORT)x, (SHORT)(y - b))	//seSetPixel(x, (SHORT)(y - b));
//    SETPIXEL((SHORT)(x + a),(SHORT) y)	//seSetPixel((SHORT)(x+a), y);
//    SETPIXEL((SHORT)(x - a),(SHORT) y)	//seSetPixel((SHORT)(x-a), y);

	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, x, (SHORT)(y+b) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, x, (SHORT)(y-b) );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+a), y );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
	GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-a), y );
	PixelOp( pixelPos, bitOffset, ColorIndex, style );
    
    do
	{
//        SETPIXEL((SHORT)(x + x0), (SHORT)(y + y0))	//seSetPixel((SHORT)(x+x0),(SHORT)(y+y0));
//        SETPIXEL((SHORT)(x - x0), (SHORT)(y + y0))	//seSetPixel((SHORT)(x-x0),(SHORT)(y+y0));
//        SETPIXEL((SHORT)(x + x0), (SHORT)(y - y0))	//seSetPixel((SHORT)(x+x0),(SHORT)(y-y0));
//        SETPIXEL((SHORT)(x - x0), (SHORT)(y - y0))	//seSetPixel((SHORT)(x-x0),(SHORT)(y-y0));

		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y+y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y+y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y-y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y-y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		
		if ( d > 0 )  
		{	
			y0--;
            dy -= two_asqr;
            d  -= dy;
        }
        x0++;
        dx += two_bsqr;
        d  += (bsqr+dx);
    } while ( dx < dy );

    d += (3*(asqr-bsqr)/2 - (dx+dy))/2;

    do
	{
//		SETPIXEL((SHORT)(x + x0), (SHORT)(y + y0))	//seSetPixel((SHORT)(x+x0), (SHORT)(y+y0));
//		SETPIXEL((SHORT)(x - x0), (SHORT)(y + y0))	//seSetPixel((SHORT)(x-x0), (SHORT)(y+y0));
//		SETPIXEL((SHORT)(x + x0), (SHORT)(y - y0))	//seSetPixel((SHORT)(x+x0), (SHORT)(y-y0));
//		SETPIXEL((SHORT)(x - x0), (SHORT)(y - y0))	//seSetPixel((SHORT)(x-x0), (SHORT)(y-y0));
        
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y+y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y+y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x+x0), (SHORT)(y-y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );
		GetPixelPosition( &pixelPos, &bitOffset, gc->vram, (SHORT)(x-x0), (SHORT)(y-y0) );
		PixelOp( pixelPos, bitOffset, ColorIndex, style );

		if ( d < 0 )
		{	
			x0++;
            dx += two_bsqr;
            d  += dx;
        }
        y0--;
        dy -= two_asqr;
        d  += (asqr-dy);
    } while (y0>=0);
//	topx = x - a;
//	topy = y - b;
//	if( gc == gSysTcbTbl[ gLcdOwnerTskId-1 ].gc )
//		WRITELCD( x - a, x + a, y - b, y+ b )      //应在前面已经定义好了px1,px2,py1,py2
}

//-----------------------------------------------------------------------
// Function name: seGray2RGB
// 
// parameters:
//			ExsrcData: The address of destination data
//			srcData: The address of source data
//			bmp: The original bit map data
//
// description:
//			realize change from white color bit into RGB color, which index is 565
//-----------------------------------------------------------------------
#ifdef COLORINDEX_GARFILED				//add this function by DSA 2004.09.20
void seGray2RGB(PIXEL*ExsrcData, BYTE *srcData, BITMAP *bmp)
{
	WORD bpp, bppcnt, pixel_unit;
	BYTE maskoffset, maskval, logbpp;
	BYTE redIndex, greenIndex, blueIndex;
	BYTE *p_srcData;
	PIXEL *index;
	DWORD i,j;
	
	bpp = bmp->info.bitcount;
	#if ( bpp >= 16 )
		return;
	#else
		index = ExsrcData;
		p_srcData = srcData;
		pixel_unit = PIXEL_UNIT>>LOG_UNIT_BYTE;
		if(bpp == 1)logbpp = 0;
		if(bpp == 2)logbpp = 1;
		if(bpp == 4)logbpp = 2;
		if(bpp == 8)logbpp = 3;

		for(j=0; j<(bmp->info.width)*(bmp->info.height); j++)
		{	
			bppcnt = bpp;
			while(pixel_unit -bppcnt >= 0)
			{
				maskoffset = ((bpp<<1)-1)<<(pixel_unit - bppcnt);
				maskval = ((*p_srcData) & maskoffset)>>(pixel_unit - bppcnt);
				redIndex = ((INDEXMAX_RED*maskval)>>logbpp);
				greenIndex = ((INDEXMAX_GREEN*maskval)>>logbpp);
       			blueIndex = ((INDEXMAX_BLUE*maskval)>>logbpp);
       			*index = ~((((PIXEL)redIndex) << INDEX_RED_OFFSET) | (((PIXEL)greenIndex) << INDEX_GREEN_OFFSET) | (((PIXEL)blueIndex) << INDEX_BLUE_OFFSET) );
       			index++;
       			bppcnt += bpp;
       			j++;				
       			if(j == (bmp->info.width)*(bmp->info.height))
       				return;
			}
       		p_srcData++;
       		j -= 1;
       	}
       #endif

	return;
}
#endif
//-------------------------------------------------------------------------
// Function name  :seRGBtoIndex()
// 
// Description    : maps the color value in RGB to a closest color index
//
// Parameters:
//     rgb: a color value in RGB format to be converted
//     index: retrieves the index value corresponding to the rgb value
// 
// No return value
//-------------------------------------------------------------------------

void seRGBtoIndex( DWORD rgb , PIXEL *index)
{
	
#if ( BITS_PER_PIXEL >= 8 )

	BYTE redIndex, greenIndex, blueIndex;

	#ifdef INDEX_WINDOWS			//RGB:888
	LinearColorMap( &redIndex, (BYTE)(( rgb >> 16 ) & 0xff), (BYTE)INDEXMAX, 0xff );
	LinearColorMap( &greenIndex, (BYTE)(( rgb >> 8 ) & 0xff), (BYTE)INDEXMAX, 0xff );
	LinearColorMap( &blueIndex, (BYTE)(rgb & 0xff), (BYTE)INDEXMAX, 0xff );
	#endif

	#ifdef COLORINDEX_GARFILED			//RGB:565
	LinearColorMap( &redIndex, (BYTE)(( rgb >> INDEX_RED_OFFSET ) & INDEXMAX_RED), (BYTE)INDEX_RED_MASK, INDEXMAX_RED );
	LinearColorMap( &greenIndex, (BYTE)(( rgb >> INDEX_GREEN_OFFSET ) & INDEXMAX_GREEN), (BYTE)INDEX_GREEN_MASK, INDEXMAX_GREEN);
	LinearColorMap( &blueIndex, (BYTE)((rgb >> INDEX_BLUE_OFFSET) & INDEXMAX_BLUE), (BYTE)INDEX_BLUE_MASK, INDEXMAX_BLUE);
	#endif
	
	*index = (((PIXEL)redIndex) << INDEX_RED_OFFSET) | (((PIXEL)greenIndex) << INDEX_GREEN_OFFSET) | (((PIXEL)blueIndex) << INDEX_BLUE_OFFSET) ;
#else
	DWORD gray;
	gray = ( 3 * ( ( rgb >> 16 ) & 0xff ) + 6 * ( ( rgb >> 8 ) & 0xff ) + ( rgb & 0xff ) );
	{
		WORD i;

		for( i = 0; i <= PixelMask; i++ )
		{
			if( gray <= GRAMPalette[i].threshold )
				break;
		}
		*index = (PIXEL)( GRAMPalette[i].rgb );
	}
#endif

	return;
}





//-------------------------------------------------------------------------
// Function name  :seClearRec()
// 
// Description    : Fill a specified rectangular with specified color
//
// Parameters:
//     gc: the point that points the current task's gc
//     x: Top left x-coordinate of the rectangular image area
//     y: Top left y-coordinate of the rectangular image area
//     width: Width of the image in pixels
//     heigth: Height of the image in pixels
//     ColorIndex: specified color value 
// 
// No return value
//-------------------------------------------------------------------------
void seClearRec(GC *gc, SHORT x, SHORT y, SHORT width, SHORT height, PIXEL ColorIndex, WORD style)
{	
	PIXEL	*lineAd;
	CHAR	bitOffset;

//	TurnOffLCD();			//Julias 2002/5/7
	GetPixelPosition( &lineAd, &bitOffset, gc->vram, x, y );
	BlockUnicolorOp( lineAd, bitOffset, width, height, ColorIndex, style, gc->vram );
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -