Click here to Skip to main content
15,890,670 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can handle double click event in listctrl of checkbox style? [modified] Pin
Cool_Dev27-Feb-11 23:57
Cool_Dev27-Feb-11 23:57 
GeneralRe: How can handle double click event in listctrl of checkbox style? Pin
Le@rner28-Feb-11 0:20
Le@rner28-Feb-11 0:20 
QuestionGetComboBoxInfo implementation Pin
mesajflaviu27-Feb-11 20:05
mesajflaviu27-Feb-11 20:05 
AnswerRe: GetComboBoxInfo implementation Pin
Andrew Brock27-Feb-11 21:28
Andrew Brock27-Feb-11 21:28 
GeneralRe: GetComboBoxInfo implementation Pin
mesajflaviu27-Feb-11 22:27
mesajflaviu27-Feb-11 22:27 
GeneralRe: GetComboBoxInfo implementation Pin
mesajflaviu27-Feb-11 22:29
mesajflaviu27-Feb-11 22:29 
QuestionBest Algorithm to merge two tree structured object? [modified] Pin
yogish29327-Feb-11 19:54
yogish29327-Feb-11 19:54 
QuestionHoe to get Alpha value of pixels of a bitmap image... [modified] Pin
Amrit Agr27-Feb-11 19:27
Amrit Agr27-Feb-11 19:27 
Hi guys... I want to show a shadow bitmap as a transparent in my application..
I have used alphablend() to do that.

m_blendfunc.BlendOp = AC_SRC_OVER;
m_blendfunc.BlendFlags = 0;
m_blendfunc.SourceConstantAlpha = 0;
m_blendfunc.AlphaFormat = AC_SRC_ALPHA;


I have changed the alpha transparency value as per intensity vaue. ( its a scrollbar value in my
application from which shadow will intense accordinagaly )

m_blendfunc.SourceConstantAlpha = int( m_intensity * 2.55 );

In OnPaint I have written..

AlphaBlend( hmemdc, prc->left	- m_shadowPosX + Border, prc->top + m_shadowPosY  + Border,  	
		    prc->right  - prc->left + borderRatio, prc->bottom - prc->top + borderRatio, 
		    hSrcDc, 0, 0, bmp.bmWidth, bmp.bmHeight, m_blendfunc );


In ReplaceColor() I have supplied shadow bitmp handle.. here _coldcolor and _cNewColor are used to
calculate a new color based on the current color( but I don't want that )..

void CPipWnd::ReplaceColor( HBITMAP &_hBmp, COLORREF _cOldColor, COLORREF _cNewColor, 
							   bool _selectRange )
{
	if ( _hBmp )
	{	
		HDC hbufferDC = CreateCompatibleDC( NULL );	// DC for Source Bitmap
		if ( hbufferDC )
		{
			HGDIOBJ hpreviousBufferObject = SelectObject( hbufferDC, _hBmp );
			// here hbufferDC contains the bitmap
			
			HDC hdirectDC = CreateCompatibleDC( NULL );	// DC for working		
			if( hdirectDC )
			{
				// 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;
				UINT * ptPixels;	// pointer used for direct Bitmap pixels access
				
				HBITMAP hdirectBitmap = CreateDIBSection( hdirectDC, ( BITMAPINFO* )&RGB32BitsBITMAPINFO, 
					DIB_RGB_COLORS, ( void** )&ptPixels, NULL, 0 );

				if ( hdirectBitmap )
				{
					// here hdirectBitmap!=NULL so ptPixels!=NULL no need to test
					HGDIOBJ hpreviousObject = SelectObject( hdirectDC, hdirectBitmap );
					BitBlt( hdirectDC, 0, 0, bm.bmWidth, bm.bmHeight, hbufferDC, 0, 0, SRCCOPY );			
					// here the hdirectDC contains the bitmap

					// Convert COLORREF to RGB 
					_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( _selectRange )
						{
							//if ( ptPixels[i] >= _cOldColor )	
                                                            //ptPixels[i] = _cNewColor;
							{
								
								COLORREF clrRef = COLORREF( ptPixels[i] );
								clrRef = COLORREF2RGB( clrRef );
								BYTE r = GetRValue( _cNewColor );
								BYTE g = GetGValue( _cNewColor );
								BYTE b = GetBValue( _cNewColor );
								BYTE *ptr = reinterpret_cast<BYTE*>( &clrRef );
								ptr[0] = *ptr;
								ptr[1] = r;
								ptr[2] = g;
								ptr[3] = b;
								ptPixels[i] = clrRef;
								
							}
						}
						else
						{
							if ( ptPixels[i] <= _cOldColor )
                                                            ptPixels[i] = _cNewColor;
						}
					}
					
					// Don't delete the result of SelectObject because it's our modified bitmap (hdirectBitmap)
					SelectObject( hdirectDC, hpreviousObject );
					// finish
				//<VIVEK.MANE> Start 2008/Jan/19
					if( _hBmp )
					{
						DeleteObject( _hBmp );
						_hBmp = NULL;
					}
					_hBmp = hdirectBitmap;
				//<VIVEK.MANE> End 2008/Jan/19
				}
				// clean up
				DeleteDC( hdirectDC );
			}
			SelectObject( hbufferDC, hpreviousBufferObject );
			// hdufferDC is now useless
			DeleteDC( hbufferDC );
		}
	}
}

My shadow bitmap (.bmp) is 24 bpp as well.I have to take alpha value of that bitmap pixels and have to
add this value in the alpha channel of the new color..
But In line
COLORREF clrRef = COLORREF( ptPixels[i] );
I am getting 0 value. Is there any mistake in the code..

Pls help me so that I can take correct alpha value of every pixels of bitmap image .

modified on Monday, February 28, 2011 4:34 AM

GeneralRe: Hoe to get Alpha value of pixels of a bitmap image... Pin
Richard MacCutchan27-Feb-11 22:24
mveRichard MacCutchan27-Feb-11 22:24 
QuestionHelp on the encryption decryption project. Pin
gateway2327-Feb-11 5:15
gateway2327-Feb-11 5:15 
AnswerRe: Help on the encryption decryption project. Pin
Hans Dietrich27-Feb-11 5:46
mentorHans Dietrich27-Feb-11 5:46 
AnswerRe: Help on the encryption decryption project. Pin
Richard MacCutchan27-Feb-11 6:15
mveRichard MacCutchan27-Feb-11 6:15 
AnswerRe: Help on the encryption decryption project. Pin
Stephen Hewitt27-Feb-11 17:58
Stephen Hewitt27-Feb-11 17:58 
QuestionIs gdi+ started? How to check? Pin
VernonM26-Feb-11 13:18
VernonM26-Feb-11 13:18 
AnswerRe: Is gdi+ started? How to check? PinPopular
Hans Dietrich26-Feb-11 14:03
mentorHans Dietrich26-Feb-11 14:03 
QuestionCButton click Pin
goorley24-Feb-11 23:23
goorley24-Feb-11 23:23 
AnswerRe: CButton click Pin
Hans Dietrich24-Feb-11 23:54
mentorHans Dietrich24-Feb-11 23:54 
AnswerRe: CButton click PinPopular
Cool_Dev25-Feb-11 0:49
Cool_Dev25-Feb-11 0:49 
GeneralRe: CButton click Pin
goorley27-Feb-11 21:51
goorley27-Feb-11 21:51 
QuestionHow can I catch FindString event on CComboBox ? Pin
_Flaviu24-Feb-11 22:11
_Flaviu24-Feb-11 22:11 
AnswerRe: How can I catch FindString event on CComboBox ? Pin
Hans Dietrich24-Feb-11 22:12
mentorHans Dietrich24-Feb-11 22:12 
AnswerRe: How can I catch FindString event on CComboBox ? Pin
Richard MacCutchan24-Feb-11 23:04
mveRichard MacCutchan24-Feb-11 23:04 
GeneralRe: How can I catch FindString event on CComboBox ? Pin
_Flaviu25-Feb-11 0:56
_Flaviu25-Feb-11 0:56 
Questionhow to set the width of scrollbar in listbox Pin
raj157624-Feb-11 20:48
raj157624-Feb-11 20:48 
AnswerRe: how to set the width of scrollbar in listbox Pin
Hans Dietrich24-Feb-11 21:07
mentorHans Dietrich24-Feb-11 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.