|
The "dumb" part was on my side, because I didn't allocate any memory. But even though now I don't get an exception anymore, the result is still the same as described on my previous posts.
Mac
|
|
|
|
|
Possibly you should have a look at the palette of the image file (the one you use for the 'unusual approach'). How is the palette defined (i.e. what is the RGBQUAD array content?)
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]
|
|
|
|
|
That was exactly what I tried, when I found the "unusual approach": What is different in the RGBQUAD, in the BITMAPHEADER, in the BITMAPINFO if I load the bitmap from the file? You know - so I could assign the exact same properties to my bitmap created with CreateDIBSection. The problem is, I didn't find a way of accessing any of the mentioned structures. The only thing I was able to find out after using LoadImage() was this (also see code from original post):
BITMAP bm;
cBmp.GetBitmap(&bm);
bm was then filled with these values
bmType 0 long
bmWidth 320 long
bmHeight 180 long
bmWidthBytes 320 long
bmPlanes 1 unsigned short
bmBitsPixel 8 unsigned short
bmBits 0x07a10000 void *
No surprise there. I assigned the same values (bmPlanes, bmBitsPixel etc.) to BITMAPINFO *lpInfo (also see original post).
Is there a way of retrieving a "proper" BITMAPINFO or BITMAPINFOHEADER from the bitmap loaded with LoadImage()?
Mac
|
|
|
|
|
MacCPlus wrote: Is there a way of retrieving a "proper" BITMAPINFO or BITMAPINFOHEADER from the bitmap loaded with LoadImage()?
No, I suppose. Anyway you may retrieve these structures loading the file yourself (see, for instance here - it looks a bit dated, but, at the moment I cannot find an up-to-date one).
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]
|
|
|
|
|
I got it!
Had to initialize bmiColors like this:
for (int n=0; n < 256; n++)
{
m_pBitmapInfo->bmiColors[n].rgbBlue=n;
m_pBitmapInfo->bmiColors[n].rgbGreen=n;
m_pBitmapInfo->bmiColors[n].rgbRed=n;
m_pBitmapInfo->bmiColors[n].rgbReserved=0;
}
Thanks for the advice!
Mac
|
|
|
|
|
It was what I intended here, since they are grey gradations, unfortunately (now I realize) I made a typo (fixed now).
Sorry for the inconvenience.
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]
|
|
|
|
|
Actually, I should have realized that myself reading your first response. But I guess I wasn't quite "there" yet.
I found out how the color table is supposed to look like by debugging bmiColors[] after having loaded said bitmap file using the code you posted.
Mac
|
|
|
|
|
Hi!
I have developed a MFC Dialog based application, that consists of buttons, combo-boxes, edit box and a button to browse for a file etc, Now i want a free tool, through which i can repeatedly automate/test my app without the involvement of human. so is there asny such free tool in which initially i will show the cursor flow on my app, then the tool will proceed to do the same for required number of times. i searched thru net, i got few like AutoHotkey and winspy ++, but they require some scripts to be written, is there any software (free) which can be used without writing scripts!!
Thanks!
|
|
|
|
|
See here for ideas.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hello Friends
I am using LoadImage to load bitmap but how can I load Tiff File?
Any Ideas?
Thanks & Regards
Yogesh
|
|
|
|
|
GDI+ won't do it for you. You could look for another library that does; I'm pretty sure GIMP does. Or you could create your own TIFF package. IIRC there might be some licensing issues.
|
|
|
|
|
Luc Pattyn wrote: GDI+ won't do it for you.
GDI+ has built-in encoders and decoders that support the following file types:
BMP
GIF
JPEG
PNG
TIFF
GDI+ reference: "Using Image Encoders and Decoders"[^].
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]
|
|
|
|
|
I stand corrected; I don't see what the OP's problem is then.
|
|
|
|
|
Are you going to update CP Vanity? I can't leave without.
Plz plz...
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]
|
|
|
|
|
There probably will be a CP Vanity 2.0 pretty soon after we get a useful web service; there still is hope, it was discussed yesterday.
And why do people insist on discussing CP Vanity everywhere except where it should be discussed, in the article's forum?
|
|
|
|
|
I stand corrected.
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]
|
|
|
|
|
BTW: you did see the CP Vanity Lite article by Nish yesterday?
|
|
|
|
|
Nope, it is pretty good (Nish rocks): thank you for signaling.
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]
modified on Friday, November 19, 2010 3:10 PM
|
|
|
|
|
|
hello guys..I read somewhere that callback function works better than the WM_TIMER in vc6. So I tried following code but it does't work. whats wrong with it?
BOOL CTimers_CallbackFuncDlg::OnInitDialog()
{
..........
..........
SetTimer(ID_CLOCK_TIMER,1000,(CALLBACK)&Timer1);
..........
}
void CALLBACK CTimers_CallbackFuncDlg::Timer1()
{
CTime curTime = curTime.GetCurrentTime();
m_sTime.Format("%d:%d:%d",curTime.GetHour(),curTime.GetMinute(),curTime.GetSecond());
UpdateData(FALSE);
}
a syntax error is given saying error C2059: syntax error : '__stdcall'
|
|
|
|
|
overloaded Name wrote: SetTimer(ID_CLOCK_TIMER,1000,(CALLBACK)&Timer1);
This could simply be:
SetTimer(ID_CLOCK_TIMER, 1000, Timer1); You could also pass NULL as the last argument and handle the WM_TIMER messages.
overloaded Name wrote: void CALLBACK CTimers_CallbackFuncDlg::Timer1()
This either needs to be a static or a global function.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
What do you mean by "callback works better"?
You need to find out the exact reason why that statement was made and if it applies to you.
Anyway, I think the error is because the callback signature is not what is expected.
Here is an excerpt from MSDN -
The lpfnTimer callback function need not be named TimerProc, but it must be defined as follows:
void CALLBACK EXPORT TimerProc(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent // timer identification
DWORD dwTime // system time
);
|
|
|
|
|
This is the term that im quoting from a text book. The auther used exactly this term for the procedure.
|
|
|
|
|
That is not good enough.
If the author has not explained why it is so, you could probably send him/her an email asking for clarification.
|
|
|
|