|
I am looking for bitmap files that contain the following information headers: BITMAPCOREHEADER, BITMAPV4HEADER, BITMAPV5HEADER.
(Note: I have all the files with BITMAPINFOHEADER that I need)
If anyone knows of any bitmap files on the www that use the above headers, please let me know.
I would like to use them to test my code and creating them my self does not garantee that they are correct.
INTP
|
|
|
|
|
is there a way to convert String to string ?
I am using c++.net forms in the form.h file when i try to get the name of a file from the texbox and open it , i get an error.
it sayd it cant convert the typr _wchar to char !!!
i used
ifstream infile;
infile.open(fileName);
|
|
|
|
|
wchar is a wide string. you need to use wstring instead of string. You can also use _bstr_t to convert automagically between them, I think it's in comutils.h.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
thanks christian
can you write it as a code i am not so sure how to use _bstr_t
eg.
char me;
Char you;
is it then right to say
me = _bstr_t(you)
and can it be used for char arrays as well?
|
|
|
|
|
_bstr_t is a string wrapper that internally contains both a wide and a narrow string. It would treat a char as a char array of one. I would use it like this:
some COM function(BSTR myBSTR, BSTR * returnBSTR)
{
std::string s(dynamic_cast<char*>_bstr_t(myBSTR));
... use the string
*returnBSTR = _bstr_t(s.c_str()).detach();
}
The syntax is probably horribly wrong, it's 12 months since I did any serious C++, but certainly that is mostly right. My string is being passed a char * in it's constructor, which comes from a temporarily created _bstr_t. The cast to char* may not be necessary, the point is that _bstr_t will construct itself from the BSTR ( wide string ) and then it's operator char* will perform the conversion for you.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
calling IWebBrowser2->Stop() for an embedded browser control does what I need, except it makes the "stop loading" click you also hear when browsing / clicking a link normally.
Can I make this "mute" (only for my control, not globall for the system), or get the effect of Stop() without the noise?
Background:
I'm using the IE Browser control for custom data display.
I've abstracted the document handling in a small helper control. The caller can set a HTML document as template (typically containing headers, and style definitions/style sheet), and then append text to the Body element. When the template is not loaded, appending Text is deferred until the DocumentComplete event fires.
Without calling Stop(), DocumentComplete gets confused with frequent Navigate() calls (setting a new template before the previous loaded).
"Vierteile den, der sie Hure schimpft mit einem türkischen Säbel."
mlog || Agile Programming | doxygen
|
|
|
|
|
People on this message board did try to help me out with this before, I got frusterated and decided to leave it for a while, then come back to it, thinking it would be easier to fix.
I have a bitmap, representing 92 of the elements from the periodic table. each of these 92 elements must have a distinct colour (using r, g, b values). I also have a .txt file containing the element symbol, name, and each of the rgb values, in the format:
Hydrogen,H,1,49,0,0
...
When the user clicks on the bitmap, I obtain the r, g, b values at the point of the click, and use those values to determine which element the user clicked on.
So, here's the problem:
When the user clicks on Hydrogen, for example, with a colour setting of 16-bits, everything works fine. But, if i change the colour settings of my monitor to 24 or 32 bits, my program reports that the user clicked on the colour 51, 0, 0. I am using photoshop (new to using this) to edit the colours of my bitmap. Still working with the Hydrogen example, photoshop says that hydrogen is set to have the colour 51, 0, 0 (no matter what my colour settings are). So I did change the entry in my text file to reflect this colour, but when I run my program, it reports that it is, in fact 49,0,0 in 16-bit and 51,0,0 for 24 and 32 bit colour.
This is how I'm obtaining the colour in my code:
COLORREF crColourAtPoint = 0;
...
crColourAtPoint = GetPixel(memDC.m_hDC, pt.x, pt.y);
CString values;
values.Format("Red: %d\nGreen: %d\nBlue: %d", GetRValue(crColourAtPoint),
GetGValue(crColourAtPoint), GetBValue(crColourAtPoint));
AfxMessageBox(values);
|
|
|
|
|
I think you're going about this the wrong way ... why do you pick depending on the color ? Why can't you just pick depending on the pixel position ? i.e. when the user clicks on one particular element "space" you only need to check it the mouse is inside the "space" ?
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Either way, I'd still have to record a bunch of information, whether it be the location of each elements space, or the colour of the element.
A few months ago I had discussed different ways of doing this with a bunch of people on here, and after a few days of going through the different options, it was decided that the clickable bitmap approach would be the best option. So I did it that way. I'm just running into a problem when switching down to 16 bit colour, as I expected. I thought that just by switching my monitor settings to 16 bit, then re-colouring the bitmap, and putting the new colour values into my .txt file my problem would be solved. I figured that if I did it that way, the colour values would remain constant between 16 bit and 24/32 bit colour, but I was wrong.
I need to know whether I'm just selecting the wrong colours, or whether there's a way to determine from within my code what colour settings the user has for their monitor, or even if this problem is fixable or not.
|
|
|
|
|
I would agree with Maximilien in that there is a better way to go.
But first the problem you are experiencing is caused by the fact you are saving the image in photoshop as a full RGB color range of 24 bits. When you go to display it on a system that cannot support that color range, the colors are down converted to the displays setting range (16 bit in this case). The solution is to save the image in Photoshop using smaller palatte. Try using Image->Mode->Index color on the menu and save to a 256 color system palatte to get you image colors downselected.
Back to your method... I would suggest you look at an article submitted last month here in CodeProject. I can't remember the name of the author but the program name was something like "Periodic Table" or PTE table.. where the author used some very good techniques to accomplish the same task of locating the periodic table element from the mouse position.
Hope this helps.
Art
|
|
|
|
|
Art Friesz wrote:
using Image->Mode->Index color on the menu and save to a 256 color system palatte
I am using indexed colour in photoshop.
Art Friesz wrote:
would suggest you look at an article submitted last month here in CodeProject. I can't remember the name of the author but the program name was something like "Periodic Table" or PTE table
This article was written by one of the guys that was helping me before, back in september. He started that article because I was asking about it back then. Seeing as I had never done anything with colours/bmp's in my applications before, I ended up needing quite a bit of help, as i guess I still do.
|
|
|
|
|
OK, if it were me and I just wanted to get this problem solved I would do one of the following:
Option 1) Compare on a range of RGB values. Example: allow a match of the RGB color provided in the txt file if the mouse pickuped a value within say 5 of each of the RGB values. In other words Hydrogen would be matched if the mouse picked up a R value between 51-5=46 and 51+5=56 and G and B was between 0 and 5.
or Option 2) (the preferred way)
Change your text file to include the percentages of the grid they occupy in the image and then pick up the mouse position on the window and convert it to percentage of the window width and height, then match the point in the rectange:
(Element Name, Element symbol, atomic no., x1,x2,y1,y2)
Example: text file would look like this:
Hydrogen,H,1,0,6,0,8
Helium,He,2,0,6,10,18
...
When you read in the txt file use the x1, x2.. for the coordinates in a CRect. Use CRect::PtInRect()to look for a match.
Art
|
|
|
|
|
I used your idea for option 1... that fixed my problem. thank you very much!
|
|
|
|
|
Windows remaps colours to best match the available palette. 4- and 8-bit modes are palettized; you can specify the palette you want to use by calling RealizePalette. You should do this in response to a WM_QUERYNEWPALETTE or WM_PALETTECHANGED message.
In 16-bit mode, the available range of colours is typically limited to 5 bits per pixel for red and blue colour information and either 5 or 6 bits per pixel for green colour information. The colour you request is mapped onto the bits available; when you request the colour of the pixel, the value is mapped back onto the 0 to 255 range. This conversion can be subject to rounding errors.
If we say that Red is limited to 5 bits of representation, that gives us values 0 to 31. Mapping your 51 in the 0-to-255 to this range gives 6.375, rounded down to 6. When getting the pixel colour, the actual 6 in the 5 bit world now becomes 48 in the 8 bit world. I assume that Windows isn't doing a direct mathematical conversion, probably factoring gamma into the equation as well, which leads to the specified 49.
Anyway, you can't rely on the colour retrieved from GetPixel being the colour you set. It's better to work with areas of an image than with colours, if possible. Alternatively, work directly with the original bitmap, rather than the on-screen representation of it.
|
|
|
|
|
I’m trying to reset the Dialog box (CFileDialog) with the last configuration set by the user (like view menu by detail and sort by date). How can I do?
I use always the Windows 2000 CFileDialog box presentation.
Denislef
|
|
|
|
|
I am having a WinApi Application. In that WinApi application I am having
a function that when called creates a web browser like gui with
interactivity and functionality to display certain kind of documents.
Now, I add an activex project to the current workspace. I make this project
dependent on the WinApi Application. I include the headers required to call
the gui displaying function in C{}. When I make the activex project I get
the following errors
warning C4273: '_getpid' : inconsistent dll linkage. dllexport assumed.
error C2065: 'NOERROR' : undeclared identifier
Please Help
|
|
|
|
|
Hi,
Can someone write a function that reverses a string in the most optimized manner? meaning it should use as few variables, loops etc as possible.
|
|
|
|
|
Why dont you try urself....??
|
|
|
|
|
This is what I got
char *start = string;
char *left = string;
char ch;
while (*string++);
string -= 2;
while (left < string)
{
ch = *left;
*left++ = *string;
*string-- = ch;
}
return(start);
Now what do u have???
|
|
|
|
|
No temps in reverseString at all, and only one loop which goes halfway along the string. It is an in-place reverse, so it overwrites whats there.
If I was feeling really keen I could turn it into a template too
#include <iostream><br />
#include <cstdio><br />
<br />
using namespace std;<br />
<br />
void reverseString(char *str, const int &len)<br />
{<br />
for(int i=0; i<(len-1)-i; ++i)<br />
str[i] ^= str[(len-1)-i] ^= str[i] ^= str[(len-1)-i];<br />
}<br />
<br />
int main()<br />
{<br />
char str[] = "String to reverse!";<br />
int len = strlen(str);<br />
<br />
cout << str << endl;<br />
reverseString(str, len);<br />
cout << str << endl;<br />
return 0;<br />
}
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
So, what's wrong with std::reverse ? The compiler's supplied library is usually pretty well optimised for the task in hand.
In the general case, forget about trying to eliminate variables, loops etc in your code. The compiler can do that when it optimises - unrolling loops, enregistering variables, removing common terms.
Compile your code in release mode for a simple implementation, then see what the compiler did with it. Shortest C++ code is not necessarily shortest or fastest object code.
So, the best optimised code is probably
void ReverseString( char* sz, size_t len )
{
char ch;
for ( size_t idx = 0; idx < len / 2; ++idx )
{
ch = sz[idx];
sz[idx] = sz[len - idx - 1];
sz[len - idx - 1] = ch;
}
} The compiler hoists the division of len by 2 out of the loop (and also converts it to a right-shift by 1). It also converts the sz[len - idx - 1] terms into a pointer and moves it back down from the end.
Finally, it uses the dl register (the least significant byte of edx to store ch , which is never stored to main memory.
Stick to simple code.
|
|
|
|
|
My guess would be this is what the lecturer is looking for too
--
The Obliterator
|
|
|
|
|
Thank you for your comments.
I agree with you that code should be simple, atleast for maintenance purposes.
|
|
|
|
|
__inline char *StrRev(char *Source, char *Dest)
{
char *p = strchr(Source, '\0'), *p2 = Dest;
while( --p >= Source )
*p2++ = *p;
*p2 = '\0';
return Dest;
};
Phil
|
|
|
|
|
Nice.
Actually the initial problem required the original string to be reversed (which i forgot to mention). I have used your nice logic to modify my function
void Reverse(char *src)<br />
{<br />
char *p = strchr(src, '\0') - 1;<br />
<br />
while (src < p)<br />
{<br />
*src ^= *p ^= *src ^= *p;<br />
src++;<br />
p--;<br />
}<br />
}
-Melwyn
|
|
|
|
|