|
Still doesn't work..not a VC++ bug?
I don't know how to use vectors..
|
|
|
|
|
Can you post the latest code?
Steve
|
|
|
|
|
|
Sorry and thanks for the reminder.
|
|
|
|
|
apoc83 wrote: I'd like to code it in c style
Then why do you use static_cast? =(bla*) should be your way
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
VuNic wrote: hen why do you use static_cast? =(bla*) should be your way
he he he... static_cast<> is not cpp specific !
"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
|
|
|
|
|
|
VuNic wrote: Most programmers learn C before C++, and get used to C style casting. When writing C++, sometimes we may be confused about when to use static_cast<> and when to use reinterpret_cast<>. In this article, I will illustrate what static_cast<> actually does, and will show some cases that will lead to errors.
I think i worked very hard last night.. it's time to sleep now
"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
|
|
|
|
|
LOLL!!! , yeah Obiviously !.. I can see the dark rings around your eyes!
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Here it is, but shorter:
if ( m_imgImgMap.IsNull() ) {
m_imgImgMap.Create( W, H, 24 );
pDoc->m_img.BitBlt( m_imgImgMap.GetDC(), 0, 0 );
m_imgImgMap.ReleaseDC();
const int iPitch = m_imgImgMap.GetPitch();
U8* pDst = static_cast< U8* >( m_imgImgMap.GetBits() );
U8* Rarray = (U8*)malloc( W*H*sizeof(U8));
U8* Garray = (U8*)malloc( W*H*sizeof(U8));
U8* Barray = (U8*)malloc( W*H*sizeof(U8));
U8 * const Rarray_org = (U8*)malloc(W*H*sizeof(U8));
U8 * const Garray_org = (U8*)malloc(W*H*sizeof(U8));
U8 * const Barray_org = (U8*)malloc(W*H*sizeof(U8));
Rarray = Rarray_org;
Garray = Garray_org;
Barray = Barray_org;
FILE * pFile;
#ifndef NO_FLOAT
pFile = fopen ("slopefloat.txt","w");
#else
pFile = fopen ("slopefixed.txt","w");
#endif
int y = 0;
int x = 0;
for ( y = 0; y < H; y++ ) {
for ( x = 0; x < W; x++ ) {
*Rarray++ = GET_R( pDst, x, y );
*Garray++ = GET_G( pDst, x, y );
*Barray++ = GET_B( pDst, x, y );
}
}
Rarray = Rarray_org;
Garray = Garray_org;
Barray = Barray_org;
int a = 0;
for ( y = 0; y < H; y++ ) {
for ( x = 0; x < W; x++ ) {
const int v = g_psSlope[(y/8)*g_iBW + (x/8)];
double mag = 0;
if ( 0 < v && v < g_iBokehWidthTh ) {
mag = 1;
} else if ( g_iBokehWidthTh <= v && v < UNKNOWN_MARK ) {
mag = .5;
} else if ( v == UNKNOWN_MARK ) {
mag = .10; // 不明
} else { // 平坦
mag = .10;
}
U8 r = static_cast< U8 >( (*Rarray++) * mag );
U8 g = static_cast< U8 >( (*Garray++) * mag );
U8 b = static_cast< U8 >( (*Barray++) * mag );
SET_RGB( pDst, x, y, r, g, b );
}
csMsg.Format( _T( "Rendering… %d%%" ), static_cast< int >( 100.0 * y / H ) );
pStatus->SetPaneText( 0, csMsg );
}
pStatus->SetPaneText( 0, _T( "" ) );
// free(pFile);
// free(Rarray);
// free(Garray);
// free(Barray); ray[i+j] = Ubuff[k];
Varray[i+j] = Vbuff[k];
k++;
}
}
}
csMsg.Format( _T( "Rendering… %d%%" ), static_cast< int >( 100.0 * y / H ) );
pStatus->SetPaneText( 0, csMsg );
}
ray[i+j] = Ubuff[k];
Varray[i+j] = Vbuff[k];
k++;
}
}
}
csMsg.Format( _T( "Rendering… %d%%" ), static_cast< int >( 100.0 * y / H ) );
pStatus->SetPaneText( 0, csMsg );
}
-- modified at 5:02 Wednesday 28th February, 2007
|
|
|
|
|
It worked!
Using this:
U8 * const Yarray_org = (U8*)malloc(W*H*sizeof(U8));
U8 * const Uarray_org const = (U8*)malloc(W*H*sizeof(U8));
U8 * const Varray_org const = (U8*)malloc(W*H*sizeof(U8));
Yarray = Yarray_org;
Uarray = Yarray_org;
Varray = Yarray_org;
everytime I did this:
*Yarray++
This is like Yarray[0], Yarray[1]...
so after incrementing to pointer, I have to
Yarray = Yarray_org; to go back to its base
(pointer) address..is this correct?
|
|
|
|
|
I am trying to retrieve the RGB code of GetPixel() and I have a slight bit of understanding of C++, I'm pretty fluent in Java and VB.net, but the first parameter for the GetPixel function has to be some sort of HDC thing, how would I return it as RGB or hexadecimal, like using it as this: GetPixel(0,50,50); returns a number that is too large for an integer 42929... Can anyone help me?
Please don't write a bunch of classes and constructors and stuff, just simple non-OOP code, best if its just one word, it's less confusing.
Thanks alot.
|
|
|
|
|
It returns a COLORREF (a DWORD in nature!), You must use GetRValue , GetGValue , and GetBValue to extract individual RGB values.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Thanks, I sorta understand what you mean, but can you tell me what additional code I need to use it/how to set it up?
|
|
|
|
|
For eg:
BYTE redValue;
BYTE greenValue;
BYTE blueValue;
redValue = GetRValue(GetPixel(hdc,50,50));
greenalue = GetGValue(GetPixel(hdc,50,50));
blueValue = GetBValue(GetPixel(hdc,50,50));
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
hdc = undeclared identifier.
|
|
|
|
|
Are you trying to get the color of a pixel on the screen? In a bitmap? If a bitmap, what form
of bitmap...Windows device independent, Windows device dependent?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
arunforce wrote: undeclared identifier.
Weird exception!;P But is it not good you learn something before asking questions? I help you out : HDC[^]
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
You only wanted one word, but for Windows graphics programming, DCs are an essential concept,
regardless of classes and OOP stuff.
If you decide you want to learn it, here's some free info: Device Contexts[^]
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
"undeclared identifier"
Your code has an error maybe compiler has an internal error;P;)
|
|
|
|
|
Sorry, I should of specified. It's just to get the pixel color of the pixel on the entire screen, doesn't matter what application or whatever, I could probably code it in VB or Java easier, but I want to make it professional. It's been a good 2 years since I've even touched C++, and it's a bit troubling.
C++'s keywords and stuff throw me off, I find that it has no relation to a similar structure, and it's a bit confusing. I probably need more experience, but then again, I'm just 17. :/
|
|
|
|
|
arunforce wrote: It's just to get the pixel color of the pixel on the entire screen
In that case, as Vunic suggested, the GetDC(NULL) API will get you a screen DC. Don't forget to
free it when you are finished with it (ReleaseDC()).
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
arunforce wrote: I could probably code it in VB or Java easier
Yup it is, when you opt for the Ignorance is bliss thinge. Just 17? Great, you are trying something good. At your age I never managed to install an IDE in my pc. The only user-made directory in my pc was "GAMES". C:\CD GAMES. lol.. it was all games.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Is there anyway to Parse a Macro with the Visual Express Debugger When I try to Step into it It says on Source Code and askss me if I want to see Assembly code
|
|
|
|
|
You could manually preprocess the file in question using the compiler's /P[^] and /C[^] options. This will product a .i file from the .c or .cpp file. Remove the .c or .cpp file in question and replace it with the .i file with the extension renamed to .c or .cpp, as the case may be. Now debug as normal.
Steve
|
|
|
|
|