コード例 #1
0
ファイル: lines.c プロジェクト: CivilPol/sdcboot
// draw a box directly to display memory
int _near Drawbox_Cmd( LPTSTR pszCmdLine )
{
	register TCHAR *pszArg, *pszLine;
	int nTop, nLeft, nBottom, nRight, nStyle, nAttribute = -1, nFill = -1, n, nFlags = 0, nShade;

	if (( pszCmdLine == NULL ) || ( *pszCmdLine == _TEXT('\0') ))
		return ( Usage( DRAWBOX_USAGE ));

	// get the arguments & colors
	if ( sscanf( pszCmdLine, _TEXT("%d%d%d%d%d%n"), &nTop, &nLeft, &nBottom, &nRight, &nStyle, &n ) == 6 ) {

		pszLine = pszCmdLine + n;
		nAttribute = GetColors( pszLine, 0 );

		// check for a FILL color
		if (( *pszLine ) && ( _strnicmp( first_arg( pszLine ), BOX_FILL, 3 ) == 0 ) && (( pszArg = first_arg( next_arg( pszLine, 1 ))) != NULL )) {

			if ( _strnicmp( pszArg, BRIGHT, 3 ) == 0 ) {
				// set intensity bit
				nFill = 0x80;
				if (( pszArg = first_arg( next_arg( pszLine, 1 ))) == NULL )
					return ( Usage( DRAWBOX_USAGE ));
			} else
				nFill = 0;

			if (( nShade = color_shade( pszArg )) <= 15 ) {
				nFill |= ( nShade << 4 );
				next_arg( pszLine, 1 );
			}
		}

		// check for a SHADOW or ZOOM
		while ( *pszLine ) {
			if ( _strnicmp( pszLine, BOX_SHADOW, 3 ) == 0 )
				nFlags |= BOX_SHADOWED;
			else if ( _strnicmp( pszLine, BOX_ZOOM, 3 ) == 0 )
				nFlags |= BOX_ZOOMED;
			next_arg( pszLine, 1 );
		}
	}

	if (( nAttribute == -1 ) || ( verify_row_col( nTop, nLeft )) || ( verify_row_col( nBottom, nRight )))
		return ( Usage( DRAWBOX_USAGE ));

	if ( nLeft == 999 ) {
		if (( nLeft = (( GetScrCols() - nRight ) / 2 )) < 0 )
			nLeft = 0;
		nRight += nLeft;
	}

	if ( nTop == 999 ) {
		if (( nTop = (( GetScrRows() - nBottom ) / 2 )) < 0 )
			nTop = 0;
		nBottom += nTop;
	}

	_box( nTop, nLeft, nBottom, nRight, nStyle, nAttribute, nFill, nFlags, 1 );

	return 0;
}
コード例 #2
0
ファイル: lines.c プロジェクト: CivilPol/sdcboot
// draw a horizontal or vertical line directly to the display
static int _fastcall __drawline( LPTSTR pszCmdLine, int fVertical )
{
	register int nAttribute = -1;
	int nRow, nColumn, nLength, nStyle, n;

	// get the arguments & colors
	if (( pszCmdLine == NULL ) || ( *pszCmdLine == _TEXT('\0') ))
		return ( Usage( (( fVertical ) ? DRAWVLINE_USAGE : DRAWHLINE_USAGE )));

	if ( sscanf( pszCmdLine, _TEXT("%d%d%d%d%n"), &nRow, &nColumn, &nLength, &nStyle, &n ) == 5 )
		nAttribute = GetColors( pszCmdLine+n, 0 );

	// if row or column == 999, center the line
	if ( nColumn == 999 ) {
		nColumn = ( GetScrCols() - (( fVertical ) ? 0 : nLength )) / 2;
		if ( nColumn < 0 )
			nColumn = 0;
	}

	if ( nRow == 999 ) {
		nRow = ( GetScrRows() - (( fVertical ) ? nLength : 0 )) / 2;
		if ( nRow < 0 )
			nRow = 0;
	}

	return ((( nAttribute == -1 ) || ( verify_row_col( nRow, nColumn )) || ( _line( nRow, nColumn, nLength, nStyle, fVertical, nAttribute, 1 ) != 0 )) ? Usage( (( fVertical ) ? DRAWVLINE_USAGE : DRAWHLINE_USAGE ) ) : 0 );
}
コード例 #3
0
ファイル: MtgCard.cpp プロジェクト: Nidhoegger/ManageMagic
inline bool MtgCard::operator==(const MtgCard& rhs) {
    return GetLayout() == rhs.GetLayout() &&
            GetManacost() == rhs.GetManacost() &&
            GetCmc() == rhs.GetCmc() &&
            CompareStringList(GetColors(), rhs.GetColors()) &&
            type == rhs.type &&
            CompareStringList(GetSupertypes(), rhs.GetSupertypes()) &&
            CompareStringList(GetTypes(), rhs.GetTypes()) &&
            CompareStringList(GetSubtypes(), rhs.GetSubtypes()) &&
            GetRarity() == rhs.GetRarity() &&
            text == rhs.GetText() &&
            GetFlavor() == rhs.GetFlavor() &&
            GetArtist() == rhs.GetArtist() &&
            GetNumber() == rhs.GetNumber() &&
            GetPower() == rhs.GetPower() &&
            GetToughness() == rhs.GetToughness() &&
            GetLoyalty() == rhs.GetLoyalty() &&
            GetMultiverseid() == rhs.GetMultiverseid() &&
            CompareIntList(GetVariations(), rhs.GetVariations()) &&
            GetImageName() == rhs.GetImageName() &&
            GetWatermark() == rhs.GetWatermark() &&
            GetBorder() == rhs.GetBorder() &&
            IsTimeshifted() == rhs.IsTimeshifted() &&
            GetHand() == rhs.GetHand() &&
            GetLife() == rhs.GetLife() &&
            IsReserved() == rhs.IsReserved() &&
            GetReleasedate() == rhs.GetReleasedate() &&
            IsStarter() == rhs.IsStarter() &&
            CompareStringPairList(GetRulings(), rhs.GetRulings()) &&
            CompareStringPairList(GetForeignNames(), rhs.GetForeignNames()) &&
            GetOriginalText() == rhs.GetOriginalText() &&
            GetOriginalType() == rhs.GetOriginalType() &&
            CompareStringPairList(GetLegalities(), rhs.GetLegalities()) &&
            GetEdition() == rhs.GetEdition();
}
コード例 #4
0
// Map the colors of the DIB (using GetNearestPaletteIndex) to a palette
//************************************************************************
void CDib::MapToPalette( HPALETTE hpal )
//************************************************************************
{
	int n, nDibColors;
	LPBYTE lpBits;
	LPRGBQUAD lpRgb;
	BYTE xlat[256];
	DWORD SizeImage;
	BOOL bChanged;

	if ( !hpal )
		return;

	if ( m_bmiHeader.biBitCount != 8 )
		return;

	if ( GetColorTableType() == DIB_PAL_COLORS )
		return;

	//	build a xlat table. from the current DIB colors to the given palette
	nDibColors = GetNumColors();
	lpRgb = GetColors();
	bChanged = NO;
	for ( n=0; n<nDibColors; n++ )
		{
		xlat[n] = (BYTE)GetNearestPaletteIndex( hpal,
			RGB(lpRgb->rgbRed, lpRgb->rgbGreen, lpRgb->rgbBlue) );
		if ( xlat[n] != n )
			bChanged = YES;
		lpRgb++;
		}

	if ( !bChanged )
		{
		// Now reset the DIB color table to match the palette
		SetColorTable( hpal, DIB_RGB_COLORS );
		return;
		}

	// translate the DIB bits
	lpBits = (LPBYTE)GetPtr();
	SizeImage = GetSizeImage();
	switch (m_bmiHeader.biCompression)
		{
		case BI_RLE8:
			xlatRle8(lpBits, SizeImage, xlat);
			break;

		case BI_RGB:
			xlatClut8(lpBits, SizeImage, xlat);
			break;
		}

	// Now reset the DIB color table to match the palette
	SetColorTable( hpal, DIB_RGB_COLORS );
}
コード例 #5
0
//	Modifies the color table of the passed DIB for use with the wUsage
//	parameter specifed.
//
//	if wUsage is DIB_PAL_COLORS the DIB color table is set to 0-256
//	if wUsage is DIB_RGB_COLORS the DIB color table is set to the RGB values
//		in the passed palette
//************************************************************************
BOOL CDib::SetColorTable( HPALETTE hpal, UINT wUsage )
//************************************************************************
{
	PALETTEENTRY ape[256];
	LPRGBQUAD pRgb;
	LPWORD pw;
	WORD wColors;
	int n, nColors;

	switch (wUsage)
		{
		// Set the DIB color table to palette indexes
		case DIB_PAL_COLORS:
			pw = (LPWORD)GetColors();
			for ( n=0; n<256; n++ )
				*pw++ = n;
			break;

		// Set the DIB color table to RGBQUADS
		default:
		case DIB_RGB_COLORS:
			if (!hpal)
				hpal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);

			GetObject( hpal, sizeof(WORD), (LPSTR)&wColors );
			nColors = min(wColors,256);
			GetPaletteEntries( hpal, 0, nColors, ape );
							
			pRgb = GetColors();
//			m_bmiHeader.biClrUsed = nColors;
			for ( n=0; n<nColors; n++ )
				{
				pRgb[n].rgbRed		= ape[n].peRed;
				pRgb[n].rgbGreen	= ape[n].peGreen;
				pRgb[n].rgbBlue		= ape[n].peBlue;
				pRgb[n].rgbReserved = 0;
				}
			break;
		}

	return TRUE;
}
コード例 #6
0
//************************************************************************
UINT CDib::GetColorTableType()
//************************************************************************
{
LPDWORD lpDWORD;

lpDWORD = (LPDWORD)GetColors();
if ( *lpDWORD == 0x00010000 ) // its looks like indices 0, 1, ...
	return( DIB_PAL_COLORS );
else 
	return( DIB_RGB_COLORS );
}
コード例 #7
0
ファイル: lines.c プロジェクト: ErisBlastar/osfree
// draw a horizontal or vertical line directly to the display
int drawline_cmd( int argc, char **argv )
{
	int attribute = -1;
	int row, col, len, width;

	// get the arguments & colors
	if (( argc >= 6 ) && ( sscanf( argv[1], "%d%d%d%d", &row, &col, &len, &width ) == 4 ))
		attribute = GetColors( argv[5], 0 );

	return ((( attribute == -1 ) || ( verify_row_col( row, col )) || ( _line( row, col, len, width,(_ctoupper( argv[0][4] ) == 'V' ), attribute, 1 ) != 0 )) ? usage( DRAWLINE_USAGE ) : 0 );
}
コード例 #8
0
ファイル: lines.c プロジェクト: ErisBlastar/osfree
// draw a box directly to display memory
int drawbox_cmd(int argc, char **argv)
{
	char *arg, *pszLine;
	int top, left, bottom, right, style, attribute = -1, fill = -1;
	int box_flags = 0;

	// get the arguments & colors
	if ((argc >= 7) && (sscanf(argv[1],"%d%d%d%d%d",&top,&left,&bottom,&right,&style) == 5)) {

		pszLine = argv[6];
		attribute = GetColors(pszLine,0);

		// check for a FILL color
		if ((*pszLine) && (_strnicmp(first_arg(pszLine),BOX_FILL,3) == 0) && ((arg = first_arg(next_arg(pszLine,1))) != NULL)) {

			if (_strnicmp(arg,BRIGHT,3) == 0) {
				// set intensity bit
				fill = 0x80;
				if ((arg = first_arg(next_arg(pszLine,1))) == NULL)
					return (usage(DRAWBOX_USAGE));
			} else
				fill = 0;

			if ((argc = color_shade(arg)) <= 15) {
				fill |= (argc << 4);
				(void)next_arg(pszLine,1);
			}
		}

		// check for a SHADOW or ZOOM
		while (*pszLine) {
			if (_strnicmp(pszLine,BOX_SHADOW,3) == 0)
				box_flags |= BOX_SHADOWED;
			else if (_strnicmp(pszLine,BOX_ZOOM,3) == 0)
				box_flags |= BOX_ZOOMED;
			(void)next_arg(pszLine,1);
		}
	}

	if ((attribute == -1) || (verify_row_col(top,left)) || (verify_row_col(bottom,right)))
		return (usage(DRAWBOX_USAGE));

	_box(top,left,bottom,right,style,attribute,fill,box_flags,1);

	return 0;
}
コード例 #9
0
//-----------------------------------------------------------------------------
// Procedurally generates the camo texture...
//-----------------------------------------------------------------------------
void CCamoMaterialProxy::GenerateCamoTexture( ITexture* pTexture, IVTFTexture *pVTFTexture )
{
	if (!m_pEnt)
		return;

#if 0
	CamoInstanceData_t *pInstanceData;
	pInstanceData = ( CamoInstanceData_t * )FindInstanceData( pEnt );
	if( !pInstanceData )
	{
		pInstanceData = ( CamoInstanceData_t * )AllocateInstanceData( pEnt );
		if( !pInstanceData )
		{
			return;
		}
		// init the instance data
	}
#endif

	Vector entityPosition;
	entityPosition = m_pEnt->GetAbsOrigin();

	QAngle entityAngles;
	entityAngles = m_pEnt->GetAbsAngles();

	// Get the bounding box for the entity
	Vector mins, maxs;
	mins = m_pEnt->WorldAlignMins();
	maxs = m_pEnt->WorldAlignMaxs();
	
	Vector traceDirection;
	Vector traceEnd;
	trace_t	traceResult;
	
	Vector forward, right, up;
	AngleVectors( entityAngles, &forward, &right, &up );
	
	Vector position, transformedPosition;
	Vector maxsMinusMins = maxs - mins;

	Vector diffuseColor[256];
	Vector baseColor;

	unsigned char camoPalette[256][3];
	// Calculate the camo palette
	//Msg( "start of loop\n" );
	int i;
	for( i = 0; i < m_CamoPatternNumColors; i++ )
	{
		GetColors( diffuseColor[i], baseColor, i,
			mins, maxsMinusMins, forward, right, up, entityPosition );
#if 1
		camoPalette[i][0] = diffuseColor[i][0] * baseColor[0] * 255.0f;
		camoPalette[i][1] = diffuseColor[i][1] * baseColor[1] * 255.0f;
		camoPalette[i][2] = diffuseColor[i][2] * baseColor[2] * 255.0f;
#endif
#if 0
		camoPalette[i][0] = baseColor[0] * 255.0f;
		camoPalette[i][1] = baseColor[1] * 255.0f;
		camoPalette[i][2] = baseColor[2] * 255.0f;
#endif
#if 0
		camoPalette[i][0] = diffuseColor[i][0] * 255.0f;
		camoPalette[i][1] = diffuseColor[i][1] * 255.0f;
		camoPalette[i][2] = diffuseColor[i][2] * 255.0f;
#endif
	}
	
	int width = pVTFTexture->Width();
	int height = pVTFTexture->Height();
	if( width != m_CamoPatternWidth || height != m_CamoPatternHeight )
	{
		return;
	}
	
	unsigned char *imageData = pVTFTexture->ImageData( 0, 0, 0 );
	enum ImageFormat imageFormat = pVTFTexture->Format();
	if( imageFormat != IMAGE_FORMAT_RGB888 )
	{
		return;
	}
	// optimize
#if 1
	int x, y;
	for( y = 0; y < height; y++ )
	{
		for( x = 0; x < width; x++ )
		{
			int offset = 3 * ( x + y * width );
			assert( offset < width * height * 3 );
			int paletteID = m_pCamoPatternImage[x + y * width];
			assert( paletteID < 256 );
#if 1
			imageData[offset + 0] = camoPalette[paletteID][0];
			imageData[offset + 1] = camoPalette[paletteID][1];
			imageData[offset + 2] = camoPalette[paletteID][2];
#else
			imageData[offset] = 255;
			imageData[offset + 1] = 0;
			imageData[offset + 2] = 0;
#endif
		}
	}
#endif
}
コード例 #10
0
// Note we only support 8bpp DIBs here, and..
// there is no regard for color table matching between the DIBs
//************************************************************************
void CDib::DibBlt(PDIB pdibDst, int dstLeft, int dstTop, int dstWidth, int dstHeight,
				  int srcLeft, int srcTop, int srcWidth, int srcHeight,
				  BOOL bTransparent, LPRGBTRIPLE lpRGB, LPTR lpLut, HPALETTE hPal )
//************************************************************************
{
HPTR pSrc, pDst;
int iScanS, iScanD, iOverrun;

if ( !pdibDst )
	return;
if ( GetBitCount() != 8 )
	return;
if ( pdibDst->GetBitCount() != 8 )
	return;

// Check the coordinate bounds, to avoid an out of range pointer
if ( srcLeft < 0 )	{ dstLeft -= srcLeft; srcWidth	+= srcLeft; dstWidth  += srcLeft; srcLeft = 0; }
if ( srcTop	 < 0 )	{ dstTop  -= srcTop;  srcHeight += srcTop;	dstHeight += srcTop;  srcTop  = 0; }
if ( dstLeft < 0 )	{ srcLeft -= dstLeft; srcWidth	+= dstLeft; dstWidth  += dstLeft; dstLeft = 0; }
if ( dstTop	 < 0 )	{ srcTop  -= dstTop;  srcHeight += dstTop;	dstHeight += dstTop;  dstTop  = 0; }

if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0 )
	return;

if ( srcLeft - GetWidth()	   >= 0 )	return;
if ( srcTop	 - abs(GetHeight()) >= 0 )	return;
if ( dstLeft - pdibDst->GetWidth()		   >= 0 )	return;
if ( dstTop	 - abs(pdibDst->GetHeight()) >= 0 ) return;

if ( (iOverrun = srcLeft + srcWidth	 - GetWidth())		> 0 )	{ srcWidth	-= iOverrun; dstWidth  -= iOverrun; }
if ( (iOverrun = srcTop	 + srcHeight - abs(GetHeight())) > 0 )	{ srcHeight -= iOverrun; dstHeight -= iOverrun; }
if ( (iOverrun = dstLeft + dstWidth	 - pdibDst->GetWidth())		> 0 )	{ dstWidth	-= iOverrun; srcWidth  -= iOverrun; }
if ( (iOverrun = dstTop	 + dstHeight - abs(pdibDst->GetHeight())) > 0 ) { dstHeight -= iOverrun; srcHeight -= iOverrun; }

if ( srcWidth <= 0 || srcHeight <= 0 || dstWidth <= 0 || dstHeight <= 0 )
	return;

// Get pointers to the start points in the source and destination
if ( !(pSrc = GetXY( srcLeft, srcTop )) )
	return;
if ( !(pDst = pdibDst->GetXY( dstLeft, dstTop )) )
	return;

// Get the scan line widths of each DIB.
iScanS = GetWidthBytes();
iScanD = pdibDst->GetWidthBytes();

// Upside down DIBs have to move backwards
if ( GetHeight() > 0 )
	 iScanS = -iScanS;
if ( pdibDst->GetHeight() > 0 )
	 iScanD = -iScanD;

if ( !bTransparent )
	{ // Copy the lines.
	while ( --srcHeight >= 0 )
		{
		hmemcpy( pDst, pSrc, srcWidth );
		pSrc += iScanS;
		pDst += iScanD;
		}
	}
else
if (lpRGB)
	{ // Copy lines with transparency mask
	WORD src, dst, wMini;
	BYTE dstPixel, srcColor, red, green, blue;
	int iSinc, iDinc, iCount;
						 
	LPRGBQUAD pTable = GetColors();
	if (lpLut)
		{
		wMini = RGB3toMiniRGB(lpRGB->rgbtRed, lpRGB->rgbtGreen, lpRGB->rgbtBlue);
		srcColor = lpLut[wMini];				
		}
	else
	if (hPal)
		{
		srcColor = (BYTE)GetNearestPaletteIndex( hPal, RGB(lpRGB->rgbtRed, lpRGB->rgbtGreen, lpRGB->rgbtBlue) );
		}
	else
		srcColor = 0;

	iSinc = iScanS - srcWidth; // Source increment value
	iDinc = iScanD - srcWidth; // Destination increment value
	while ( --srcHeight >= 0 )
		{
		iCount = srcWidth;	  // Number of pixels to scan.
		while ( --iCount >= 0 )
			{
			src = (WORD)(*pSrc++);
			// Copy pixel only if it isn't transparent.
			if (src == 0)
				pDst++;
			else
			if (src == 255)
				*pDst++ = srcColor;
			else
				{
				if (src > 127)
					++src;
				dst = 256-src;
				dstPixel = *pDst;
				red = (BYTE)((((WORD)lpRGB->rgbtRed * src) + ((WORD)pTable[dstPixel].rgbRed * dst)) >> 8);
				green = (BYTE)((((WORD)lpRGB->rgbtGreen * src) + ((WORD)pTable[dstPixel].rgbGreen * dst)) >> 8);
				blue = (BYTE)((((WORD)lpRGB->rgbtBlue * src) + ((WORD)pTable[dstPixel].rgbBlue * dst)) >> 8);
				if (lpLut)
					{
					wMini = RGB3toMiniRGB(red, green, blue);
					*pDst++ = lpLut[wMini];					
					}
				else
				if (hPal)
					{
					*pDst++ = (BYTE)GetNearestPaletteIndex( hPal, RGB(red, green, blue) );
					}
				else
					{
					pDst++;
					}
				}
			}

		pSrc += iSinc;
		pDst += iDinc;
		}
	}
else
	{ // Copy lines with transparency.
コード例 #11
0
// Create a GDI palette from a DIB color table
//************************************************************************
HPALETTE CDib::CreatePalette()
//************************************************************************
{
// create an identity palette from the DIB's color table
return ( CreateIdentityPalette( GetColors(), GetNumColors() ) );
}
コード例 #12
0
//	Will read a file in DIB format and return a global HANDLE to its
//	BITMAPINFO.	 This function will work with both "old" and "new"
//	bitmap formats, but will always return a "new" BITMAPINFO
//************************************************************************
BOOL CDib::ReadBitmapInfo( HFILE fh )
//************************************************************************
{
	DWORD off, size;
	HANDLE hbi = NULL;
	int i, nNumColors;
	LPRGBQUAD pRgb;
	BITMAPINFOHEADER bi;
	BITMAPCOREHEADER bc;
	BITMAPFILEHEADER bf;

	if ( fh < 0 )
		return FALSE;

	off = _llseek(fh,0L,SEEK_CUR);

	if (sizeof(bf) != _lread(fh,(LPSTR)&bf,sizeof(bf)))
		return FALSE;

	// do we have a RC HEADER?
	if (bf.bfType != BFT_BITMAP)
		{
		bf.bfOffBits = 0L;
		_llseek(fh,off,SEEK_SET);
		}

	if (sizeof(bi) != _lread(fh,(LPSTR)&bi,sizeof(bi)))
		return FALSE;

	// what type of bitmap info is this?
	if ( (size = bi.biSize) == sizeof(BITMAPCOREHEADER) )
		{
			bc = *(LPBITMAPCOREHEADER)&bi;
			bi.biSize				= sizeof(BITMAPINFOHEADER);
			bi.biWidth				= (DWORD)bc.bcWidth;
			bi.biHeight				= (DWORD)bc.bcHeight;
			bi.biPlanes				= (UINT)bc.bcPlanes;
			bi.biBitCount			= (UINT)bc.bcBitCount;
			bi.biCompression		= BI_RGB;
			bi.biSizeImage			= 0;
			bi.biXPelsPerMeter		= 0;
			bi.biYPelsPerMeter		= 0;
			bi.biClrUsed			= 0;
			bi.biClrImportant		= 0;
			_llseek(fh,(long)sizeof(BITMAPCOREHEADER)-sizeof(BITMAPINFOHEADER),SEEK_CUR);
		}

	//!!! hack for BI_BITFIELDS
	if ( bi.biCompression == BI_BITFIELDS && !bi.biClrUsed )
		bi.biClrUsed = 3;

	// Copy in the bitmap info header
	m_bmiHeader = bi;
	FixHeader();
	nNumColors = GetNumColors();
	pRgb = GetColors();

	if (nNumColors)
		{
		if (size == sizeof(BITMAPCOREHEADER))
			{
			// convert old color table (3 byte entries) to new (4 byte entries)
			_lread(fh,(LPVOID)pRgb,nNumColors * sizeof(RGBTRIPLE));

			for (i=nNumColors-1; i>=0; i--)
				{
				RGBQUAD rgb;

				rgb.rgbRed		= ((LPRGBTRIPLE)pRgb)[i].rgbtRed;
				rgb.rgbBlue		= ((LPRGBTRIPLE)pRgb)[i].rgbtBlue;
				rgb.rgbGreen	= ((LPRGBTRIPLE)pRgb)[i].rgbtGreen;
				rgb.rgbReserved = (BYTE)0;

				pRgb[i] = rgb;
				}
			}
		else
			{
			_lread(fh,(LPVOID)pRgb,nNumColors * sizeof(RGBQUAD));
			}
		}

	if (bf.bfOffBits)
		_llseek(fh,off + bf.bfOffBits,SEEK_SET);

	return TRUE;
}
コード例 #13
0
void Mesh::GetColors(int index, Vector *V)
{
	GetColors(faces[index].points, V);
}
コード例 #14
0
ファイル: TextStyleListBox.cpp プロジェクト: pdrezet/brix
void TextStyleListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{

//CRect members to store the position of the items
CRect rItem;
CDC* dc = CDC::FromHandle(lpDrawItemStruct->hDC);

if ((int)lpDrawItemStruct->itemID < 0)
{
// If there are no elements in the CListBox
// based on whether the list box has Focus  or not 
// draw the Focus Rect or Erase it,
if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS))
{
    dc->DrawFocusRect(&lpDrawItemStruct->rcItem);
}
else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && !(lpDrawItemStruct->itemState & ODS_FOCUS)) 
{
    dc->DrawFocusRect(&lpDrawItemStruct->rcItem); 
}
   return;
}


// String to store the text
CString csStyle;

// Get the item text.
GetText(lpDrawItemStruct->itemID, csStyle);

//Initialize the CListBox Item's row size
rItem = lpDrawItemStruct->rcItem;

UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER;
if (GetStyle() & LBS_USETABSTOPS)
nFormat |= DT_EXPANDTABS;


	COLORREF cText;
	COLORREF cBg;
	CFont font;
	font.CreatePointFont(100,"Times New Roman"); 
	LgbColorsDef cColors;
	GetColors(csStyle, cColors);
	cText = RGB(cColors.m_iFgRed, cColors.m_iFgGreen, cColors.m_iFgBlue);
	cBg = RGB(cColors.m_iBgRed, cColors.m_iBgGreen, cColors.m_iBgBlue);

// If CListBox item selected, draw the highlight rectangle.
// Or if CListBox item deselected, draw the rectangle using the window color.
if ((lpDrawItemStruct->itemState & ODS_SELECTED) &&
(lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
{
    CBrush br(::GetSysColor(COLOR_HIGHLIGHT));
    dc->FillRect(&rItem, &br);
}
else if (!(lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & ODA_SELECT)) 
{
	dc->FillSolidRect(&rItem, cBg);
    //CBrush br(::GetSysColor(COLOR_WINDOW));
    //dc->FillRect(&rItem, &br);
}
else if (!(lpDrawItemStruct->itemState & ODS_SELECTED)) {
	dc->FillSolidRect(&rItem, cBg);
}

// If the CListBox item has focus, draw the focus rect.
// If the item does not have focus, erase the focus rect.
if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS))
{
    dc->DrawFocusRect(&rItem); 
}
else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) && !(lpDrawItemStruct->itemState & ODS_FOCUS))
{
    dc->DrawFocusRect(&rItem); 
}

// To draw the Text in the CListBox set the background mode to Transparent.
int iBkMode = dc->SetBkMode(TRANSPARENT);

	dc->SetBkColor(cBg);
	dc->SetTextColor(cText);
	dc->SelectObject(&font);

	//Draw the Text
	dc->TextOut(rItem.left, rItem.top, csStyle);

	// create memory device context
	CDC* pSrcMemDC = new CDC;
	assert( NULL != pSrcMemDC );

	pSrcMemDC->CreateCompatibleDC(dc);

	// RGB + Alpha
	int totalBytes = rItem.Width() * rItem.Height() * 4;

	// create bitmap
	CBitmap* pSrcBmp = new CBitmap;
	assert( NULL != pSrcBmp );

	// initialize
	pSrcBmp->CreateCompatibleBitmap(dc, rItem.Width(), rItem.Height());
	pSrcMemDC->SelectObject(pSrcBmp);

	void *byteArr = new BYTE [ totalBytes ];
	assert( NULL != byteArr );

	BYTE *tmp = (BYTE *) byteArr;

	// set the flagged array to the bitmap
	pSrcBmp->SetBitmapBits( totalBytes, byteArr );

	// Write text using EHS font blitter
	LgbTextIcon dumTextIcon;
	CString csFont = GetFont(csStyle);
	EhsWidgetClass* pWidget;
	EhsTgtViewportSurfaceClass* pSurface = NULL;
	EhsGraphicsColourClass xFgColour, xBgColour;
	EhsGraphicsFontClass* pFont = dumTextIcon.GetFontPtr(csFont);

	if (0) {
		//if (pFont) {
			//xFgColour = EhsGraphicsColour_argb(cColors.m_iFgRed, cColors.m_iFgGreen, cColors.m_iFgBlue, cColors.m_iFgAlpha);
			xFgColour = EhsGraphicsColour_argb(150, 150, 150, 150);
			xBgColour = EhsGraphicsColour_argb(255, 255, 255, 0);
			EhsWidgetTable_init(&EhsWidgetTable);
			pWidget = EhsWidgetTextbox_init(rItem.left, rItem.top, 0, rItem.Width(), rItem.Height(), xFgColour, xBgColour, pFont);
			EhsWidget_create(pWidget);
			EhsGraphicsColourClass xPalette[2];
			xPalette[0] = EHS_WIDGET_TEXTBOX(pWidget).xBgColour;
			xPalette[1] = EHS_WIDGET_TEXTBOX(pWidget).xFgColour;
		
			pSurface = EhsTgtViewportSurface_create(NULL,pWidget->xCurRect.nWidth,pWidget->xCurRect.nHeight,EHS_GRAPHICS_COLOUR_A1,xPalette,2);

			if (pSurface) {
			EhsWidgetTextbox_draw(pWidget, NULL, NULL, pSurface);

			// Copy the written data back from the bitmap
			pSrcBmp->GetBitmapBits( totalBytes, byteArr );

			// Blit Text
			int x,y;
		
			for (y = 0; y < rItem.Height(); y++) {
				int nPixIdx = y * rItem.Width() * 4;
				int nBmpIdx = y * ((pSurface->nWid+7)/8);
				for (x = 0; x < rItem.Width(); x++) {
					int nBit = 1 << (7u - (x % 8u));
					int nX = x*4;
					if ((nBit & EhsTgtViewportSurface_bitmap(pSurface)[nBmpIdx + x/8]) == nBit) {
						tmp[nPixIdx+nX] = (unsigned char) cColors.m_iFgBlue;
						tmp[nPixIdx+nX+1] = (unsigned char) cColors.m_iFgGreen;
						tmp[nPixIdx+nX+2] = (unsigned char) cColors.m_iFgRed;
						tmp[nPixIdx+nX+3] = (unsigned char) cColors.m_iFgAlpha;
					} else {
						tmp[nPixIdx+nX] = 255;
						tmp[nPixIdx+nX+1] = 255;
						tmp[nPixIdx+nX+2] = 255;
						tmp[nPixIdx+nX+3] = 0;
					}
				}
			}
		
			if (!pWidget->bOptimiseForSpeed) {
				EhsTgtViewportSurface_destroy(NULL, pSurface);
			}
			}
		}
/*
	// Copy this data into bitmap
	pSrcBmp->SetBitmapBits( totalBytes, byteArr );

	BLENDFUNCTION bf;
	bf.BlendOp = AC_SRC_OVER;
	bf.BlendFlags = 0;
	bf.SourceConstantAlpha = 255;
	bf.AlphaFormat = AC_SRC_ALPHA; 

	AlphaBlend(
		dc->GetSafeHdc(),
		rItem.left, 
		rItem.top, 
		rItem.Width(),
		rItem.Height(),
		pSrcMemDC->GetSafeHdc(),
		0,
		0,
		rItem.Width(),
		rItem.Height(),
		bf );
		
	int PicSizeX = 30;
	int PicSizeY = 16;
	pSrcMemDC->SelectObject(pSrcBmp);
	dc->BitBlt(rItem.left+5, rItem.top+1, PicSizeX, PicSizeY, pSrcMemDC, 0, 0, SRCCOPY);
*/
	pSrcMemDC->DeleteDC();
	delete pSrcMemDC;

	pSrcBmp->DeleteObject();
	delete pSrcBmp;

	delete [] byteArr;

}