|
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 );
if ( hbufferDC )
{
HGDIOBJ hpreviousBufferObject = SelectObject( hbufferDC, _hBmp );
HDC hdirectDC = CreateCompatibleDC( NULL );
if( hdirectDC )
{
BITMAP bm;
GetObject( _hBmp, sizeof( bm ), &bm );
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;
HBITMAP hdirectBitmap = CreateDIBSection( hdirectDC, ( BITMAPINFO* )&RGB32BitsBITMAPINFO,
DIB_RGB_COLORS, ( void** )&ptPixels, NULL, 0 );
if ( hdirectBitmap )
{
HGDIOBJ hpreviousObject = SelectObject( hdirectDC, hdirectBitmap );
BitBlt( hdirectDC, 0, 0, bm.bmWidth, bm.bmHeight, hbufferDC, 0, 0, SRCCOPY );
_cOldColor = COLORREF2RGB( _cOldColor );
_cNewColor = COLORREF2RGB( _cNewColor );
for ( int i = ( ( bm.bmWidth * bm.bmHeight ) - 1 ); i >= 0; --i )
{
if( _selectRange )
{
{
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;
}
}
SelectObject( hdirectDC, hpreviousObject );
if( _hBmp )
{
DeleteObject( _hBmp );
_hBmp = NULL;
}
_hBmp = hdirectBitmap;
}
DeleteDC( hdirectDC );
}
SelectObject( hbufferDC, hpreviousBufferObject );
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
|
|
|
|
|
Your question is very difficult to read. Please use the edit button and put your code snippets between <pre></pre> tags so it is formatted and readable.
I must get a clever new signature for 2011.
|
|
|
|
|
hello friends, i am pursuing my degree and i am in my final semester.
I need to know how every file is stored on a disk i.e. if a application want to access any file i.e. any video,audio,document file, is there a common way, how every file stored on the disk.
|
|
|
|
|
Sure, we'll be glad to help.
Tell us what you've found so far, and we'll go from there.
|
|
|
|
|
gateway23 wrote: is there a common way, how every file stored on the disk.
Yes, every file is merely a stream of bytes (or bits) and can be accessed in exactly the same way. The difficulty is knowing how to interpret each byte to make sense of the information. However, I doubt if that knowledge is of any use to you; perhaps it would be better if you explained exactly what problem you are trying to solve.
I must get a clever new signature for 2011.
|
|
|
|
|
This is a vague question and I get the impression that if I knew exactly what you're asking:
- I probably wouldn't know the answer.
- An explanation would take more space than available here.
Steve
|
|
|
|
|
Greets,
How can I tell programatically, Is gdi+ already started? Is there a function for this?
Thanks...vmars316
|
|
|
|
|
You could try calling one of the GDI+ functions and checking if it returns GdiplusNotInitialize .
|
|
|
|
|
I have a CButton derived class. I would like this class to handle the click event itself. What should I put in my message map for the button class? ON_BN_CLICKED doesn't work.
|
|
|
|
|
ON_BN_CLICKED just wraps a WM_COMMAND message. You probably want to catch WM_LBUTTONUP messages.
|
|
|
|
|
goorley wrote: I would like this class to handle the click event itself.
use ON_CONTROL_REFLECT() message map.
BEGIN_MESSAGE_MAP(CMyBtn, CButton)
ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
END_MESSAGE_MAP()
void CMyBtn::OnClicked()
{
}
TN062: Message Reflection for Windows Controls
|
|
|
|
|
Works like a charm!
|
|
|
|
|
Hi . I want to ask you something : how can I catch FindString event on an CComboBox ? I try in some ways but I failed ... I want to give my functionality when I call FindString on that control ... thank you kindly !
|
|
|
|
|
How did you try? What did you do?
|
|
|
|
|
I think you may have to derive your own class from CComboBox [^] and add your functionality the derived class.
I must get a clever new signature for 2011.
|
|
|
|
|
After all , I did it in follow way :
BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
and
BOOL CComboBoxExt::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if(message == CB_FINDSTRING)TRACE("\n bingo \n");
return CComboBox::OnWndMsg(message, wParam, lParam, pResult);
}
|
|
|
|
|
i want to change the width of verticalscrollbar of list box using mfc
|
|
|
|
|
Step 1: Remove style WS_VSCROLL from listbox
Step 2: Create your own listbox object, derived from CListBox, and in the Create() function create your own CScrollBar object, whose width you can then set.
Step 3: Hook up all the scroll messages.
|
|
|
|
|
Hi,
I create one WPF window using in C# code. How to this window use in Vc++ win32 GUI?
actually i want how to integrate WPF window designs in vc++ win32/mfc environment?
How to add WPF files(like C# and xaml) in Vc++ win32/mfc project?
Pls share ur ideas or urls?
Regards,
M.Mathivanan
|
|
|
|
|
|
I have already answered this question here[^]. Try doing some research for yourself on how to expose the COM interfaces from a C# program. You could start by looking at the articles here on CodeProject.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi,
I want to be able to convert a double to an integer. Say the double variable is a decimal, like 1.732. If I use int() to convert it, I will get 2. I just want the whole number of the double variable, 1, without any rounding. How do I do this in C++?
modified 21-Dec-20 21:02pm.
|
|
|
|
|
I would try a simple cast.
Warning: whatever you end up with, make sure it works the way you want it for negative numbers too!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Don't typecasts round the decimal to a whole number when going from double to integer? And isn't int() a typecast?
BTW thanks for the help...
modified 21-Dec-20 21:02pm.
|
|
|
|
|
did you try anything? did you look it up in your C++ book? did you google it?
see, asking questions is the easy part.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|