|
|
|
How to get the size of memory pointed by void * pointer?
Thanks in advance!
|
|
|
|
|
Generally there is no way that will work on all conditions. How ever if you are sure that, the pointer will be pointing to a memory allocated using new operator, you can use the _msize function.
|
|
|
|
|
You could use _msize()[^]. For instance,
#include "malloc.h"
...
void* pPointer = new BYTE[100];
int size = _msize( Ptr );
Please note that it won't work if the memory is allocated in stack. Only for memory allocated on heap. Hope it helps.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thank You.
Now how do I write any structure to a xml node?
Any idea?
Thanks in advance!
|
|
|
|
|
Ah! Now i got the context about what you're trying to do. Export the BITMAP to XML? Bravo! i'd say.
IMHO, Instead of dumping the BITMAP structure to XML, just get the bitmap data by calling GetBitmapBits()[^] and other necessary information such as width, height, color depth and save that to XML file. Later on by loading these values, you can recreate the bitmap by calling the function - CreateBitmap()[^]. Hope this helps you.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
yo buddy.. that will surely help. Thanks!
|
|
|
|
|
I have a BITMAP structure. I need to write it to a xml file.
How do I do this?
|
|
|
|
|
However the hell you want!!?!
Define the structure you'll use to store the info, then fill it - simple.
If you need a prod-along, why not just make the XML file hold ( a subset of) the same info as the BMP file would, in the same order.
E.g for a 5x5 pixel red square, I may use something like:
<BitmapFile>
<FileInfo>
<Width>5</Width>
<Height>5</Height>
<BitPlanes>1</BitPlanes>
<BitsPixel>24</BitPixel>
<CompressionType>0</CompressionType>
<xPixelsMeter>2835</xPixelsMeter>
<yPixelsMeter>2835</yPixelsMeter>
<ColsUsed>0</ColsUsed>
<ColsImportant>0</ColsImportant>
</FileInfo>
<ColorData>
<ScanLine> FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 </ScanLine>
<ScanLine> FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 </ScanLine>
<ScanLine> FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 </ScanLine>
<ScanLine> FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 </ScanLine>
<ScanLine> FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 </ScanLine>
</ColorData>
<BitmapFile>
One of the many problems with his approach is, that I can't remember if compressed pixels runs are allowed to cross scanLine boundaries (one compressed stream may not end at the end of the scanline it was begun in)
Please excuse me if it's a little forward, but why don't you use ZLib? Instead of busting up all the files for transfer and storing the info into a single large XML file, you could just compress the files together into an archive, and send that. This should provide you with smaller transfers & faster execution since the files are all binary rather than textual representations of the same binary data.
|
|
|
|
|
thanks for your suggestions.
Let me give you broader view of what Im trying to do..
Im developing an application that needs to send xml files to a mac system. A similar app on mac should be able to open and interpret the files.
Now the xml file has a header and a data parts.
The Data part will contain multiple node hierarchies as the one that follows:
<item>
<id> 123 </id>
....
....
<note> some notes</note>
<image>
<bitmap>
<height></height>
<width> </width>
...
</bitmap>
</image>
</item>
So I can use zlib on such multipe xml files.
what say..
Please suggest.
|
|
|
|
|
I am using the following code to choose the font from font dialog box . now after popup the font dialog box ,I select the font type size color and other properties .Now after clicking the ok button ,I want to display the all information in different comboboxes . my query is how can I get this information out from the font dialog box . I used the following code .
CHOOSEFONT cf; // common dialog box structure
static LOGFONT lf; // logical font structure
static DWORD rgbCurrent; // current text color
HFONT hfont, hfontPrev;
DWORD rgbPrev;
//Initialize CHOOSEFONT
ZeroMemory(&cf, sizeof(CHOOSEFONT));
cf.lStructSize = sizeof (CHOOSEFONT);
cf.hwndOwner = hdWnd;
cf.lpLogFont = &lf;
cf.rgbColors = rgbCurrent;
cf.Flags = CF_SCREENFONTS | CF_EFFECTS;
if (ChooseFont(&cf)==TRUE) {
hfont = CreateFontIndirect(cf.lpLogFont);
Trioum
|
|
|
|
|
What about documentation [^]?
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]
|
|
|
|
|
Still I am not able to get the 1. font size
2.style regular bold and bold italic
Trioum
|
|
|
|
|
Because you didn't read carefully the documentation.
For instance, LOGFONT 's lfHeight member looks promising when searching for font size.
lfItalic also maybe useful piece of info and so on...
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]
|
|
|
|
|
|
lf.lfFaceName giving the right font name that I select but lf.lfHeight giving the arbitrary wrong negative values. how can I solve it
Trioum
|
|
|
|
|
trioum wrote: lf.lfHeight giving the arbitrary wrong negative values
As MSDN tells you, you can use the following formula to specify a height for a font with a specified point size:
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
So you can use a simple function like the following to get the (positive) point size (which is what the font dialog displays) from the LOGFONT height:
int GetFontPointSize(int nHeight)
{
HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
ASSERT(hdc);
int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
::DeleteDC(hdc);
int nPointSize = MulDiv(nHeight, 72, cyPixelsPerInch);
if (nPointSize < 0)
nPointSize = -nPointSize;
return nPointSize;
}
Note that you must use logical units for the lfHeight parameter in the LOGFONT struct. To get logical units from point size, you can use following function:
int GetFontHeight(int nPointSize)
{
HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
ASSERT(hdc);
int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
::DeleteDC(hdc);
int nHeight = -MulDiv(nPointSize, cyPixelsPerInch, 72);
return nHeight;
}
|
|
|
|
|
Hi. Why my progress bar ctrl doesn't apply smooth style although I set it's 'Smooth' property to TRUE???
I'm working in VS2008.
Thanks.
|
|
|
|
|
Load the resource file in a text editor, and look for the progress control there - make sure the styles are as you expect.
You can also use Spy++ to find the control, and look at its styles.
This is assuming the control is part of a dialog, and created automatically. If you use CreateWindow(Ex) yourself, then look at your code.
Also, many control styles are only valid at creation - using SetWindowLong (xxx_STYLE, blah)[*] won;t affect them.
Iain.
[*] too lazy to look it up, but I hope it makes the point.
|
|
|
|
|
Thanks Iain.
I've looked up using Spy++ and PBS_SMOOTH is present!?
The control is part of dialog, added on from toolbox on the dialog.
I don't use any code like 'CreateWindow...' or setting any style with 'SetWindowLong...'
Strange?
Also, forget to mention I'm on XP.
|
|
|
|
|
josip cagalj wrote: Also, forget to mention I'm on HP.
I saw your original post! I'm more of a fan of Heinz myself...
Not sure what to recommend really. I'd suggest starting an empty project with a dialog and progress bar.
Build up from there - see what you're doing differently.
Iain.
|
|
|
|
|
Once again thanks.
I'll do that, relay nothing else to try.
|
|
|
|
|
OK.
I've tried opening new project (dialog based) and put progress ctrl on dialog with smooth property and still nothing. I've did some surfing on net and found similar questions, they suggested (over at MSDN) to change windows theme to classic. After doing so, my progress ctrl did work with smooth style applied but come on that can't be solution!?
I don't wont to do that!
|
|
|
|
|
hello all. I am reading some data from xml file. I memcpy it to a BITMAP structure variable. Now I need to convert this to HBITMAP. how do I do this?
|
|
|
|