Ejemplo n.º 1
0
void CThumbEditor::SaveParams()
{
	if(FrameColor.IsWindowEnabled())
		thumb_->setColor("FrameColor", COLORREF2RGB(FrameColor.GetColor()));
	if(Color1.IsWindowEnabled())
		thumb_->setColor("GradientColor1", COLORREF2RGB(Color1.GetColor()));
	if(ThumbTextColor.IsWindowEnabled())
		thumb_->setColor("TextColor", COLORREF2RGB(ThumbTextColor.GetColor()));

	if(StrokeColor.IsWindowEnabled())
		thumb_->setColor("StrokeColor", COLORREF2RGB(StrokeColor.GetColor()));
	
	if(Color2.IsWindowEnabled())
	thumb_->setColor("GradientColor2", COLORREF2RGB(Color2.GetColor()));
	
	if(thumb_->existsParam("DrawFrame"))
	{
		bool DrawFrame = SendDlgItemMessage(IDC_DRAWFRAME, BM_GETCHECK)!=0;
		thumb_->setParam("DrawFrame", DrawFrame);
	}
	if(thumb_->existsParam("FrameWidth"))
		thumb_->setParam("FrameWidth", GetDlgItemInt(IDC_FRAMEWIDTH));
	
	CString text  = GuiTools::GetWindowText(GetDlgItem(IDC_THUMBTEXT));
	bool AddText  = SendDlgItemMessage(IDC_ADDFILESIZE, BM_GETCHECK)!=0;
	
	thumb_->setParamString("Text", WCstringToUtf8(text));
	if(thumb_->existsParam("DrawText"))
		thumb_->setParam("DrawText", AddText);

	//if(thumb_->existsParam("Font"))
	{
		CString res;
		FontToString(&ThumbFont, res);
		thumb_->setParamString("Font", WCstringToUtf8(res));
	}

}
Ejemplo n.º 2
0
HBITMAP CNoteDlg::ReplaceColor(HBITMAP hBmp, COLORREF cOldColor, COLORREF cNewColor, HDC hBmpDC)
{
    HBITMAP RetBmp = NULL;
    if (hBmp)
    {	
        HDC BufferDC = CreateCompatibleDC(NULL);	// DC for Source Bitmap
		if (BufferDC)
		{
			HBITMAP hTmpBitmap = (HBITMAP) NULL;
			if (hBmpDC)
				if (hBmp == (HBITMAP)GetCurrentObject(hBmpDC, OBJ_BITMAP))
				{
					hTmpBitmap = CreateBitmap(1, 1, 1, 1, NULL);
					SelectObject(hBmpDC, hTmpBitmap);
				}
				
				HGDIOBJ PreviousBufferObject = SelectObject(BufferDC,hBmp);
				// Here BufferDC contains the bitmap
				
				HDC DirectDC = CreateCompatibleDC(NULL); // DC for working		
				if (DirectDC)
				{
					// Get bitmap size
					BITMAP bm;
					GetObject(hBmp, sizeof(bm), &bm);
					
					// Create a BITMAPINFO with minimal initilisation 
					// for the CreateDIBSection
					BITMAPINFO RGB32BitsBITMAPINFO; 
					ZeroMemory(&RGB32BitsBITMAPINFO,sizeof(BITMAPINFO));
					RGB32BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
					RGB32BitsBITMAPINFO.bmiHeader.biWidth = bm.bmWidth;
					RGB32BitsBITMAPINFO.bmiHeader.biHeight = bm.bmHeight;
					RGB32BitsBITMAPINFO.bmiHeader.biPlanes = 1;
					RGB32BitsBITMAPINFO.bmiHeader.biBitCount = 32;
					
					// Pointer used for direct Bitmap pixels access
					UINT * ptPixels;	
					
					HBITMAP DirectBitmap = CreateDIBSection(DirectDC, 
						(BITMAPINFO *)&RGB32BitsBITMAPINFO, 
						DIB_RGB_COLORS,
						(void **)&ptPixels, 
						NULL, 0);
					if (DirectBitmap)
					{
						// Here DirectBitmap!=NULL so ptPixels!=NULL no need to test
						HGDIOBJ PreviousObject = SelectObject(DirectDC, DirectBitmap);
						BitBlt(DirectDC,0,0,
							bm.bmWidth,bm.bmHeight,
							BufferDC,0,0,SRCCOPY);					
						// Here the DirectDC contains the bitmap
						
						// Convert COLORREF to RGB (Invert RED and BLUE)
						cOldColor = COLORREF2RGB(cOldColor);
						cNewColor = COLORREF2RGB(cNewColor);
						
						// After all the inits we can do the job : Replace Color
						for (int i=((bm.bmWidth*bm.bmHeight)-1); i>=0; i--)
						{
							if (ptPixels[i] == cOldColor) ptPixels[i] = cNewColor;
						}
						// Little clean up
						// Don't delete the result of SelectObject because it's 
						// our modified bitmap (DirectBitmap)
						SelectObject(DirectDC,PreviousObject);
						
						// Finish
						RetBmp = DirectBitmap;
					}
					// Clean up
					DeleteDC(DirectDC);
				}			
				if (hTmpBitmap)
				{
					SelectObject(hBmpDC, hBmp);
					DeleteObject(hTmpBitmap);
				}
				SelectObject(BufferDC,PreviousBufferObject);
				// BufferDC is now useless
				DeleteDC(BufferDC);
		}
    }
    return RetBmp;
}