|
I'd like to display a few bitmaps as layers, something like in Adobe Photoshop. First to display one bitmap (layer), then alphablend next bitmap (layer) and then next, and next, and... To do this I prepered array of 32_bit_per_pixel bitmaps (with alpha channel): HBITMAP hBitmaps[10];.
Code looks like this:
BLENDFUNCTION m_blend;<br />
m_blend.BlendOp = AC_SRC_OVER;<br />
m_blend.BlendFlags = 0;<br />
m_blend.SourceConstantAlpha = 255;<br />
m_blend.AlphaFormat = AC_SRC_ALPHA;<br />
<br />
i = 0;<br />
while( i<n )<br />
{<br />
dcTmp.SelectObject( hBitmaps[i++] );<br />
<br />
AlphaBlend( dcLayout.m_hDC,<br />
x, y, uWidth, uHeight,<br />
dcTmp.m_hDC,<br />
0, 0, uWidth, uHeight, <br />
m_blend );<br />
}
Creating these bitmaps I'm using is OK. Alphablending is also working OK when bitmaps has alpha channel set to 255 for each pixel.
But there seem to be a problem, when bitmaps has transparent alpha channel. I also want to display transparent layer (later user will be able to draw on this layer). Each pixel in this transparent layer has alpha channel with value = 0 (so it's totaly transparent).
When this layer is filled with white color RGB(255,255,255) it isn't transparent, but when is filled with, for example, RGB(200,0,0) or RGB(0,0,0), then layer is transparent but not totaly, only in 80-90%! :/
I also see that: when layer is a photography or some picture pixels with alpha channel less then 255 are not partly transparent but partly white! :/
I dont't know what I may do wrong. Can you help me?
~~~~
|
|
|
|
|
Whats problem or What do yo need?
whitesky
|
|
|
|
|
Hi
We know if we allocate memory in stack we must give its size before.But in heap the size is not importatnt i know.We allocate it then we delete it.
But this code gives error at the runtime.(HEAP CORRUPTION DETECTED)
<br />
int main ()<br />
{<br />
char* mytext = new char[];<br />
cout << "Enter name";<br />
cin >> mytext;<br />
cout << mytext;<br />
delete[] mytext;<br />
return 0;<br />
}<br />
if i give size like char* mytext = new char[8]; it does not give error.
1-)So why do we need heap?I see that i can not allocate memory dynamicly.I must give size like stack allocation.
2-)Can you explain me please how i can fix error.
3-)I want to allocate memory dynamicly(unknown size until runtime) in heap with new.How can i do this?
I am looking for your answers.
Thanks..
-- modified at 17:08 Thursday 6th July, 2006
|
|
|
|
|
sawerr wrote: I want to allocate memory dynamicly(unknown size until runtime) in heap with new.How can i do this?
you can not allocate an unknown amount of memory. you must specify an amount when you do the allocation.
the easiest way to handle the problem is to use a string class (like std::string) that can handle the allocation for you, automatically:
#include < string >
...
std::string mytext;
cout << "Enter name";
cin >> mytext;
cout << mytext;
why do you new dynamic allocation? you need it so you can allocate memory that is larger than the size of the stack. you can also use it so that subroutines can allocate objects and variables whose number and/or size are unknown to the caller at compile-time.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Thanks Chris
I know string class.But i want to understand memory much more detail.
How can i do this allocation with a char pointer in heap.
Is there a way?CAn you please give me much details about heap allocation.Whay do we need it?Differences between stack.
Thanks again.
|
|
|
|
|
sawerr wrote: How can i do this allocation with a char pointer in heap.
i am not sure of how the string class handles this, but one way to do this is:
1. allocate 100 chars on the heap
2. read 100 chars from input into your buffer
3. re-allocate the buffer with another 100 chars
4. go to 2
stop when you reach the End Of File.
sawerr wrote: Whay do we need it?Differences between stack
you can't allocate as much memory on the stack as you can from the heap.
BYTE *p = new BYTE[1000000] will work.
BYTE p[1000000] will probably fail
Cleek | Image Toolkits | Thumbnail maker
-- modified at 18:09 Thursday 6th July, 2006
|
|
|
|
|
hmm ok i understand.
I have one more question.It is very important for me
In my first code at runtime debugger gives HEAP CORRUPTION DETECTED as i said
But for this code:
<br />
char* mytext = new char[]; <br />
mytext = "Enter name"; <br />
delete[] mytext; <br />
return 0;<br />
DEbug assertion Failed!
Expression : _BLOCK_TYPE_IS_VALID
What is the differences these errors?Here in compile time compiler can see the length:
"Enter name" is 11(with null).But still can not allcate it in heap and still gives error at runtime as i said.
Can you please explain this?
thanks for all help.
|
|
|
|
|
sawerr wrote: char* mytext = new char[];
i can't even get that statement to compile.
you absolutely need to specify a number of elements to allocate:
ex.
char* mytext = new char[100];
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
class RTI_EXPORT RTIambassador {<br />
public:<br />
#include "RTIambServices.hh"<br />
RTIambPrivateData* privateData;<br />
private:<br />
RTIambPrivateRefs* privateRefs;<br />
};
I didn't know the meaning of having two names beside the name Class like this:
class RTI_EXPORT RTIambassador
Someone gave me an answering saying the class is intended to be exported from a DLL.
What is meant by a class being exported from a DLL. Does this mean that this specific code here is a a little chunk of a code from a DLL file and is being used by the current file Im working with? Or does it mean, tell the DLL linker to add this specific class onto the linker as an addition function.
I'm very confused here. Someone help me out. Thanks in advance
Cheers,
Jay -
|
|
|
|
|
Jay03 wrote: RTI_EXPORT
Could be anything, but it is likely a preprocessor defined symbol to be either __declspec(dllexport) or __declspec(dllimport) .
http://en.wikipedia.org/wiki/Dynamic_link_library[^]
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
So how is the class related to the linker. Does the class I mentioned add onto the functions that is already in the DLL. Very confusing
Thanks.
|
|
|
|
|
I am located in NH and I am working with a client that has an old Visual C++ application that they would like updated. I have a working copy of the program and some source code. I am trying to get the source compiled. The working copy uses OCX controls and the Mfc40.dll indicating that it was last compiled in Visual C++ 4.0. However the only good copy of the source that they can find uses VBX controls and seems to be a Visual C++ 1.5 project.
I have VC++ 4.0 and VC++ 1.5 on my computer. I have a limited knowledge of C++ and I am looking for some one to help me get the source set up in either VC++ 1.5 or VC++ 4.0 enabling me to trace through the code and understand the logic. I am looking for someone in the NH or MA area that could help me getting this program back into shape. If you are interested, or know of someone who would be interested, let me know what your fee would be to update this program.
|
|
|
|
|
Not much progress in two months eh?
roland51 wrote: enabling me to trace through the code and understand the logic.
No documentation I guess?
roland51 wrote: help me getting this program back into shape.
Doesn't sound like it ever was in shape.
roland51 wrote: If you are interested, or know of someone who would be interested, let me know what your fee would be to update this program.
Including moving to NH and working on this dream project I would guess around 4.5 million dollars US, sound about right?
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
led mike wrote: I would guess around 4.5 million dollars US, sound about right?
wow, do you like to share that fortune with me
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
|
Wow, I've done that several times, though mostly without the VBX controls, except I'm 2000 miles too far to the west.
(This reminds me when I "ported" an app from the Mac to Windows. The [Asymetrix] Toolbook source code had long been lost and wouldn't have been very useful even if we'd had it. I just copied the look and feel. The result was so much better they hired a contractor to rewrite the Mac version but then cancelled the project for financial reasons.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
roland51 wrote: If you are interested, or know of someone who would be interested, let me know what your fee would be to update this program.
I can't help you with the job because I am too far away but I do believe you missed a few things that make esitmating this type of thing very difficult.
How many lines of code is the current application?
Does everything compile cleanly? After reading your post again, I guess you don't know this answer as this sounds like what you want the programmer to do.
Do you want to port it to a Microsoft supported compiler?
John
|
|
|
|
|
Hi fellows
I add in my app the comutil.h. I have a problem in the declaration of the throw exception. My compiler informs this:
<br />
540 C:\Dev-Cpp\include\comutil.h declaration of `OLECHAR* _bstr_t::Detach()' throws different exceptions <br />
152 C:\Dev-Cpp\include\comutil.h than previous declaration `OLECHAR* _bstr_t::Detach() throw ()' <br />
The code that is in the comutil.h for the first error is this:
<br />
inline BSTR _bstr_t::Detach()<br />
{<br />
_COM_ASSERT(m_Data != NULL && m_Data->RefCount() == 1);<br />
<br />
if (m_Data != NULL) {<br />
BSTR b = m_Data->GetWString();<br />
m_Data->GetWString() = NULL;<br />
_Free();<br />
return b;<br />
} <br />
else {<br />
_com_issue_error(E_POINTER);<br />
<br />
return NULL;<br />
}<br />
}<br />
For the second error, this is the code:
BSTR Detach() throw();
What I have to do in this case? May I comment the second line??
Thanks for the support
|
|
|
|
|
Alex Cutovoi wrote: BSTR Detach() throw();
I don't have Visual Studio accessible at the moment, but I believe this header file is suppose to declare that method as follows:
BSTR Detach() throw(...);
or simply:
BSTR Detach();
The throw() tells the compiler that the method does not throw an exception.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac, thanks for help now and in the question that I posted before.
I change this thing to the second way that you said:
BSTR Detach();
Now I have some others, linker compiler errors:
[Linker error] undefined reference to `_ZN9_com_util19ConvertStringToBSTREPKc@4'
[Linker error] undefined reference to `_Z16_com_issue_errorl@4'
[Linker error] undefined reference to `_Z16_com_issue_errorl@4'
What is this man?
Thanks again for the great and big support
|
|
|
|
|
Looks like you might be linking to the wrong library. Is this an application linking with a static library by chance?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Dear sir,
I do know what i do
When I compile my program now i have this error :
Making help file...
Error executing c:\windows\system32\cmd.exe.
paie.exe - 1 error(s), 0 warning(s)
What to do now to correct this error ?
I learn my self
|
|
|
|
|
Does this happen with all projects, or just the one? Does the project actually have a help file?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
THis happens for just one project,
I have help file
|
|
|
|
|
Can you be more specific
whitesky
|
|
|
|