|
Alright, i got it. The deal is actually to erase these while fields in wm_paint after call StretchBlt
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Hi, I want to use AlphaBlend() method to display transparent shadow. I requires some sort of calculation to mix color value from bitmap( for which I have to display shadow ) with other color( shadow color ).
I have referred caculation method from msdn it's not giving me proper result. I am giving the code. Pls help me out.
DWORD destRedColor = 0;
DWORD destBlueColor = 0;
DWORD destGreenColor = 0;
DWORD destAlphaColor = 0;
DWORD SrcRedColor = 0;
DWORD SrcBlueColor = 0;
DWORD SrcGreenColor = 0;
DWORD SrcAlphaColor = 0;
int src_const_alpha = 0;
for ( int i = ( ( bm.bmWidth * bm.bmHeight ) - 1 ); i >= 0; --i )
{
COLORREF clrRef = ptPixels[i];
clrRef = COLORREF2RGB( clrRef );
DWORD redDest = GetRValue( clrRef );
DWORD greenDest = GetGValue( clrRef);
DWORD blueDest = GetBValue( clrRef);
BYTE *ptrAlphaDest = reinterpret_cast<BYTE*>( &clrRef );
DWORD alphaDest;
alphaDest = ptrAlphaDest[0];
DWORD redSrc = GetRValue( _cNewColor );
DWORD greensrc = GetGValue( _cNewColor );
DWORD blueSrc = GetBValue( _cNewColor );
BYTE *ptrAlphaSrc = reinterpret_cast<BYTE*>( &_cNewColor );
DWORD alphaSrc;
alphaSrc = ptrAlphaSrc[0];
src_const_alpha = int( m_intensity * 2.55 );
SrcRedColor = redSrc * src_const_alpha / 255.0;
SrcGreenColor = greensrc * src_const_alpha / 255.0;
SrcBlueColor = blueSrc * src_const_alpha / 255.0;
SrcAlphaColor = alphaSrc * src_const_alpha / 255.0;
destRedColor = SrcRedColor + ( 1 - SrcAlphaColor ) * redDest;
destGreenColor = SrcGreenColor + ( 1 - SrcAlphaColor ) * greenDest;
destBlueColor = SrcBlueColor + ( 1 - SrcAlphaColor ) * blueDest;
destAlphaColor = SrcAlphaColor + ( 1 - SrcAlphaColor ) * alphaDest;
ptPixels[i]
= (destAlphaColor << 24 ) |
(destRedColor << 16 ) |
(destGreenColor << 8 ) |
(destBlueColor);
}
modified on Wednesday, March 2, 2011 10:19 PM
|
|
|
|
|
If you do not post any code or indicate the exact problem, all we can help you with is to wish you good luck.
|
|
|
|
|
Hi, I want to use AlphaBlend() method to display transparent shadow. I requires some sort of calculation to mix color value from bitmap( for which I have to display shadow ) with other color( shadow color ).
I have referred caculation method from msdn it's not giving me proper result. I am giving the code. Pls help me out.
DWORD destRedColor = 0;
DWORD destBlueColor = 0;
DWORD destGreenColor = 0;
DWORD destAlphaColor = 0;
DWORD SrcRedColor = 0;
DWORD SrcBlueColor = 0;
DWORD SrcGreenColor = 0;
DWORD SrcAlphaColor = 0;
int src_const_alpha = 0;
for ( int i = ( ( bm.bmWidth * bm.bmHeight ) - 1 ); i >= 0; --i )
{
COLORREF clrRef = ptPixels[i];
clrRef = COLORREF2RGB( clrRef );
DWORD redDest = GetRValue( clrRef );
DWORD greenDest = GetGValue( clrRef);
DWORD blueDest = GetBValue( clrRef);
BYTE *ptrAlphaDest = reinterpret_cast<BYTE*>( &clrRef );
DWORD alphaDest;
alphaDest = ptrAlphaDest[0];
DWORD redSrc = GetRValue( _cNewColor );
DWORD greensrc = GetGValue( _cNewColor );
DWORD blueSrc = GetBValue( _cNewColor );
BYTE *ptrAlphaSrc = reinterpret_cast<BYTE*>( &_cNewColor );
DWORD alphaSrc;
alphaSrc = ptrAlphaSrc[0];
src_const_alpha = int( m_intensity * 2.55 );
SrcRedColor = redSrc * src_const_alpha / 255.0;
SrcGreenColor = greensrc * src_const_alpha / 255.0;
SrcBlueColor = blueSrc * src_const_alpha / 255.0;
SrcAlphaColor = alphaSrc * src_const_alpha / 255.0;
destRedColor = SrcRedColor + ( 1 - SrcAlphaColor ) * redDest;
destGreenColor = SrcGreenColor + ( 1 - SrcAlphaColor ) * greenDest;
destBlueColor = SrcBlueColor + ( 1 - SrcAlphaColor ) * blueDest;
destAlphaColor = SrcAlphaColor + ( 1 - SrcAlphaColor ) * alphaDest;
ptPixels[i]
= (destAlphaColor << 24 ) |
(destRedColor << 16 ) |
(destGreenColor << 8 ) |
(destBlueColor);
}
|
|
|
|
|
Hi all,
the function SetWindowExtEx() is returning false for me sometimes. I am using MM_ANISOTROPIC mapping mode.
GetLastError() is returning error code 50(The request is not supported).
This is happening very rarely and only during print operation.
Can size may be a problem.
|
|
|
|
|
Hi,
I don't know, however what I would do is this:
add some code to log all parameter values and the return value and the GetLastError value (only when it failed!) to a file when it succeeds and when it fails. Looking at those numbers is likely to tell you what is going on.
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.
|
|
|
|
|
Hi
I am using ReadFile with overlapped i\o in synchronous mode. I have 2 questions.
while (true)
{
BOOL b = ReadFile(hSource, &buffer, 200, &k, &ov);
if ((b && k ) == 0)
{
break;
}
ov.Offset = ov.Offset + k;
}
}
The file that program reads is bigger than 200 byte so it must not return EOF. But it does.
When it reads first phase
b = 0 (TRUE), k == 0 which means synchronous read operation gets to the end of a file as described here:
http://msdn.microsoft.com/en-us/library/aa365690%28v=vs.85%29.aspx[^]
My first question is, why does program return EOF even though file 6KB.
My second question is,
I want to read file in a loop as seen here:
ov.Offset = ov.Offset + k;
But i don't understand what is the differences between offset and offsethigh. I mean which one must be increased? I don't really understand the effect of offset and offsethigh. First i thought offset must be beginning and offsethigh is the ending so i must advanced both of them but i think this is not true.
Thanks...
|
|
|
|
|
Hi,
I'm only handling the second question: the file offset once was simply a 32-bit number; later on it had to become a 64-bit number (in order to handle very large files), and MS has chosen to represent such 64-bit number as a struct containing two 32-bit numbers called xyzHigh and xyz. Their combined value equals (xyzHigh<<32)+xyz , so what you need to do is add to the lower part, and if an overflow occurs, add that to the higher 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.
|
|
|
|
|
I believe the way you're making the check is not right.
For an overlapped operation, no. of bytes read, k in this case will always be 0 .
The actual bytes read is taken using GetOverlappedResult .
Now assume ReadFile returns TRUE , in which case b will be 1 .
So now we have k with a value of 0 and b with a value of 1 , which is a perfect result for an overlapped read.
Consider the check if ((b && k) == 0) .
This translates to if ((1 && 0) == 0) .
Which further translates to if (0 == 0) .
Now this becomes true and the program thinks it has reached EOF.
Here is an excerpt from the documentation on how to check for EOF in a overlapped read operation -
if the file is opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, the return value is zero (0) and GetLastError returns ERROR_HANDLE_EOF when the file pointer goes beyond the current end of file
|
|
|
|
|
Are you sure that the initial values in your OVERLAPPED structure are correct? Have you checked the error code when ReadFile() returns FALSE ? Lastly, are you sure it is a good idea to use overlapped IO for what is such a simple file read?
I must get a clever new signature for 2011.
|
|
|
|
|
Richard MacCutchan wrote: Lastly, are you sure it is a good idea to use overlapped IO for what is such a simple file read?
Good point, indeed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the answers, I got it.
How can you advance file pointer if you don't use overlapped IO?
|
|
|
|
|
hi
is there any way to filter the only memory leaks which is due to code written by me,not internal code?
Actually what happens ,i caused only 3 memory leaks in my code,but there are 61 memory leaks displayed by the vld.
|
|
|
|
|
There is no such thing as a valid memory leak. IMO you should fix them all.
Are you maybe saying there are false positives? In that case you should report it to the author of the tool.
|
|
|
|
|
If there are internal memory leaks, it is highly likely that you are not using the APIs or functions correctly.
|
|
|
|
|
There is a method to get m_hWnd of dropdown list of CComboBox , of course , except GetComboBoxInfo(...) ?
I need to get that handle to work on Windows NT SP6 , and there I haven't COMBOBOXINFO struct and GetComboBoxInfo ...
I try this[^] method , but is not good for me for two reason :
1. Don't function 'nCtlColor == CTLCOLOR_LISTBOX' part , I don't know why
2. This handle will be avaiable only after I clicked to dropdown button of CComboBox , and I needed in PreSublclassWindow already .
Thank you .
|
|
|
|
|
I don't know the answer, but I will give you a few ideas.
Are you sure this is not just an SDK version problem? Have you tried sending the CB_GETCOMBOBOXINFO to the combobox on WinNT? If it's not in the SDK, you can define it along with a COMBOBOXINFO struct and then send the message for testing purposes. Nothing bad will happen, and you will see if the COMBOBOXINFO data changes. If it does, fine, if it doesn't you will need another approach.
Most of the MSDN documentation says minimum supported client = Windows 2000 professional, even though the messages has been around since at least Win 3.1. AddString[^] example.
Are you sure the list box is even created when you want to subclass the control?
Finally, have a look at the implementation of a ComboTree[^].
|
|
|
|
|
i have string that may contain unicode character,i want to write that strings into text file,replacing unicode character with unicode values
|
|
|
|
|
|
Hi,
I suppose you want something like this (C++):
#include <sstream>
#include <iterator>
size_t OutputByteVals(const std::wstring ws, std::ostream& out)
{
const size_t nBytes = ws.size() * sizeof(wchar_t);
std::copy_n(reinterpret_cast<const char *>(ws.data()), nBytes , std::ostream_iterator<int>(out, " "));
return nBytes;
}
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Wednesday, March 2, 2011 3:22 AM
|
|
|
|
|
Hi, I have a SDI project, its view is derived from CRichEditView.I already knew how to TextOut a the outline of some text (the example of MSDN CDC::BeginPath).Right now I want to press keyboard "a",and the outline of "a" show in the view, just like the effect of MS Word. How can I do?
modified on Wednesday, March 2, 2011 12:39 AM
|
|
|
|
|
Select the text, then set the CHARFORMAT2 info. Note the CFM_OUTLINE value.
|
|
|
|
|
Thank you Hans!
I tried your method,but it didn't work. MSDN says"CFE_OUTLINE - Characters are displayed as outlined characters. The value does not affect how the control displays the text." Does that mean the selected text is set to "CFM_OUTLINE", but keep the display unchanged?
|
|
|
|
|
If I keeping calling this code it eventually crashes:
locale mylocale("");
ostringstream os;
os.imbue(mylocale);
Anyone know why?
|
|
|
|
|
Where does it crash? Do you have kernel symbols set up? What function?
|
|
|
|