|
Nick Usechak wrote:
I believe my problem is with the BITMATINFO structure I am not sure how to deal with the fact that RGBQUAD is of size [1]?
that 1 is misleading. the number of RGBQUADs is either 0, 2, 16 or 256. what you really need to know is that the palette immediately follows the BITMAPINFOHEADER, always.
so try allocating the BITMAPINFOHEADER and the palette in a single chunk of memory (allocate sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256). then, fill in the BMIH. then start filling in the palette immediately after the BMIH. pass that as the BITMAPINFO to StretchDIBits.
Nick Usechak wrote:
What I currently have seems to work for most of the bitmap(it displays a gradient of gray as it should) but then random colors appear on the bottom of my screen (and I am not using the BITMAPINFO structure as I am sure I should).
DIBs are stored bottom-down (bottom left pixel is the first byte in the pixel array). so if you see garbage at the bottom, that's a good sign that you're overwriting the start of the image pixels.
also note that the width of a DIB row needs to be an even multiple of 4. your code works for your 8x8 image, but will fail with a 9x8.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris,
I did as you suggested (I think):
I changed bmH.biSize = sizeof(BITMAPINFOHEADER);
in my code to
bmH.biSize = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256;
but it did not work. I tried some other options (before bugging you again) and found that if I use
bmH.biSize = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*34;
it works. But this makes no sense (to me) 256-the number of elements in my palette sure, but 34? I did not change anything else in my code, I think that I have the order correct? I also changed the order of my BITMAPINFOHEADER and RGBQUAD but that had no effect on the result?
By the way thanks for the tip about this only working for an even multiple of 4, otherwise I would have been perplexed about that next.
Is there any easy workaround for that?
Thanks
Nick
|
|
|
|
|
Nick Usechak wrote:
changed bmH.biSize = sizeof(BITMAPINFOHEADER
no, not like that, like this:
BYTE *pDIBHeader = new BYTE[sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256];
BITMAPINFOHEADER *pBMIH = (BITMAPINFOHEADER *)pDIBHeader;
pBMIH ->biSize = sizeof(BITMAPINFOHEAER);
etc..
RGBQUAD *pPal = (RGBQUAD *)(pDIBHeader + sizeof(BITMAPINFOHEADER));
for (int i=0; i < 256; i++)
{
pPal[i].rgbRed = pPal[i].rgbGreen = pPal[i].rggBlue = i;
}
StretchDIBits(... pDIBHeader, surface,...);
ie. make the palette and the BMIH contiguous in memory by allocating them together. biSize should always be the size of the BITMAPINFOHEADER struct itself (or one of the newer variants, which are all bigger than the original).
Nick Usechak wrote:
By the way thanks for the tip about this only working for an even multiple of 4, otherwise I would have been perplexed about that next.
Is there any easy workaround for that?
there's no workaround. that's simply how windows expects image data: bottom-up, DWORD-padded (ie. multiple of 4 bytes per row) and BGR order for 24 or 32 bit data.
Cleek | Image Toolkits | Thumbnail maker
-- modified at 15:56 Wednesday 14th September, 2005
|
|
|
|
|
Thanks a lot Chris that solved my problem, I appreciate your help.
-Nick
|
|
|
|
|
|
One small thing I can add - you are not forced to work with inverted (top-down) images.
To work with bottom-up images, set the bitmap header biHeight parameter to a negative value.
|
|
|
|
|
Hey all I hope you can help,
I need to open a dos console from within my windows enviornment, I have used CreateProcess() to do this once before but this case is more complicated.
My dos console, (lets call it (foo.exe)) takes a binary file(lets call it(input.file)) and converts it into 0-3 text files and a log file. foo.exe also requires keyboard input so that the user can tell foo.exe which of the
0-3 files to produce. What I need to do is supply foo.exe with the input.file and redirect a text file(lets call this key.txt) into foo.exe to handle the keyboard input. I can open foo.exe with just input.file and it works great, but I need this whole process to be transparent to my user, hence the need to bring key.txt in to the mix.
I have tried both a using the cmd.exe and a batch file approach and trying to do the redirection directly from the commandd line neither way works. I am not sure if I was even doing the cmd.exe, batch file version of this correctly, since I could never get it to work.
Here is what I have at the moment.
CreateProcess( NULL,
lpCommandLine,
NULL,
NULL,
0,
dwCreateFlags, <-- Set to CREATE_NEW_CONSOLE
NULL,
NULL,
&si,
&pi );
lpCommandLine is set as follows:
(I fudged the path names but you will get the general idea)
"C:\Documents and Settings\bob\very very\long\path\foo.exe "C:\Documents and Settings\bob\very very\long\path\input.file" < "C:\Documents and Settings\bob\very very\long\path\key.txt""
I have been looking around on this for a few days and know that the quotes can be a big problem?
My current permutation above opens the console window for a split second but nothing happens, the directory where the files should be created remains unchanged.
Thanks for any suggestions.
|
|
|
|
|
The easiest way to do this is to put that long command line in a batch file and run the batch file via CreateProcess() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I went and tried what you suggested and I get the same result it opens the console for a split second but nothing happens,
I was able to shorten the length of the command line to
"C:\Documents and Settings\bob\very very\long\path batch.bat"
batch file = (foo input.file < key.txt)
This batch filel will work outside of my program but not when called from within it.
Any Ideas
|
|
|
|
|
Nitefall2060 wrote:
batch file = (foo input.file < key.txt)
Go ahead and qualify these three files with a path, too.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
You can do two things first
echo "input" | foo.exe
Second:
Create a Pipe Using CreatePipe Assign the out side of the pipe to the STARTUPINFO.hStdInput then set STARTUPINFO.dwflags = STARTF_USESTDHANDLES the call create process with bInheritHandles = true. The use writefile to write to the pipe and yo should be good.
A programer trapped in a thugs body
|
|
|
|
|
ky_rerun wrote:
You can...
Thanks, but I think you meant to send this to Nitefall2060.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
|
I can answer this one! This drove me batty a while ago. You cannot combine the lines together in the arguments to CreateProcess. From my code:
int rc = CreateProcess(CalExe, Arguments, NULL, NULL, NULL, 0, NULL, NULL, NULL, &ProcInfo);
CalExe has nothing but "c:\blah\file.exe". Arguments contains the arguments. I have NO idea why one would code it this way but such is life.
C. Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
|
|
|
|
|
Does any one know how I can Manipulate Views consisting of field values from several tables using Visual C++. I want to Insert new records in one instance,Update Data in another instance and delete data using MS SQL Views.
|
|
|
|
|
How can I shutdown a remote PC after saving all the running applications on it?
|
|
|
|
|
hey, i started building my app in VC++6 and i want to access an IE window's javascript to retrieve the contents of an HTML input box. how can i do that? can you post a sample script?
|
|
|
|
|
I created an own MFC web browser, fetched some interfaces to MSHTML and retrieved the contents that way.
Maybe there is also a way to get the MSHTML interface by injecting a DLL or by creating a toolbar...
Don't try it, just do it!
|
|
|
|
|
I hear there's a simple way to do it using DOM, but how?
|
|
|
|
|
I have an MFC application based on Document/View Architecture which is also an MDI application. I am able to add ToolBar and StatusBar in MDI Child window but instead I need to add menu to MDI child windows. Is there any trick available to add menu in MDI Child window? Per MSDN, MDI Child window can not have its own menu. Please help.
|
|
|
|
|
I can replace the floating frame class in my application with my own ( derived class from CMiniDockFrameWnd )
by using something like :
m_pFloatingFrameClass = RUNTIME_CLASS(MyMiniFrame);
but it replaces all the floating frames for the application ( toolbars, floating windows, ... )
Is there a way to have a different class for each toolbar ( for example ) so that I can do something special for each ?
I'm trying to set a minimum size on the floating window with OnGetMinMaxInfo, but when doing so, it also set the size for the toolbars ( when floating ) and do it will create a frame that is larger than the actual size of the toolbar.
Thanks.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I have created a modeless dialog. I am passing in the pointer to the parent window - which happens to be a CFormView derived class.
m_pModeless = new CModelessDialogHeap(this);
Now when I want to get the parent pointer (m_pModeless) from the modeless dialog I can do two things. A. Store the pointer passed into the constructor of the modeless dialog and use that -- which works.
B. Or, according to one article on this site "http://thecodeproject.com/dialog/gettingmodeless.asp" I should be able to use GetParent().
When I do, it doesn't. It returns an empty pointer
CWnd * tmpPtr = this->GetParent();
What am I missing? Thanks!
|
|
|
|
|
|
Sorry I dont' know what you mean. The dialog is created via clicking a button on a CFormView derived class and its pointer (this) is passed to the Modeless Dialog constructor.
|
|
|
|
|
a window's parent is set by the code that creates the window (in the case of a modeless dialog, that's generally your code). if you don't set a parent wnd (usually in the dlg ctor, or in Create) it will remain NULL.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|