|
pcpro178 wrote: Is there a simple API for getting the file size? Something like GetFileSize?
You mean something like GetFileSize()[^]? Yeah, there is.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Well, yes, but GetFileSize requires a variable of type HANDLE to be passed to it. I have a FILE variable instantiated, but how do I go from one to the other?
|
|
|
|
|
If you insist on the FILE pointer, you can do this:
fseek(file, 0, SEEK_END);
filesize = ftell(file);
fseek(file, 0, SEEK_SET);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
There are multiple ways including the following simplified code (will not compile):
FILE* pFile = fopen();
if (pFile)
{
int fileNum = _fileno(pFile)
HANDLE hFile = (HANDLE) _get_osfhandle(fileNum);
GetFileSize(hFile);
}
|
|
|
|
|
Thanks! This was a huge help!
|
|
|
|
|
I need to draw an image that is able to zoom in many times, the image in question is of a city. Currently I am drawing the image using a .bmp file, the problem is when I zoom in too much I get the blocky, pixelation associated with .bmp files. I would like some suggestions, ideas, tutorials, etc. on what I should do to keep the fidelity of the image a any zoom level. Should I use a paging scheme for the drawing, is it possible to draw some vector based image or I there something else I should be looking into? General info: drawing using MFC GDI functions, the current image size is around 100 mb. Thanks in advance for any guidance.
|
|
|
|
|
I suggest you try PhotoShop first to resize your image smaller for multiple times.
If PS can not do it well, you should give up.
Or you may need to use jpg format to zoom in your image - zoom in with jpg is better than bitmap format.
|
|
|
|
|
includeh10 wrote: zoom in with jpg is better than bitmap format
Really, have you tried it?
It's the same, except now you have jpg artifacts all over the place.
|
|
|
|
|
includeh10 wrote: zoom in with jpg is better than bitmap format
neither format has any influence on the ability to zoom on the final image. after decoding either, you get an array of pixels - and pixels are pixels, regardless of where they came from.
|
|
|
|
|
tealomp wrote: the problem is when I zoom in too much I get the blocky, pixelation associated with .bmp files
that's not BMP files, that's just what you get when you zoom in on a raster-based image. at some point, there's just not enough information in the original file to zoom in any further - there's no way to interpolate any more data between the source pixels and you end up magnifying the source pixels themselves. this is true regardless of the source of the image or the algorithm used to zoom (though some algorithms are better than others).
tealomp wrote: what I should do to keep the fidelity of the image a any zoom level
there is no way to do such a thing with a raster-based image.
on the other hand, vector-based images can scale to any size. or, you could do something like MrSID, which is an image format that blends images of multiple resolutions to allow for smooth zooming over a large range. it's used primarily for satellite data.
|
|
|
|
|
when i programming this night, i come up against some difficulties.
i use c-free 4.1
let's see the program first:
=========================================================
#include<iostream.h>
#define PI 3.141529
void main()
{
float radius;
float area = 2*radius*PI;
cout << "Plz input the radius:\n";
cin >> radius;
cout << "The area is " << area << endl;
}
=========================================================
so, very easy right! but, something happens:
i input 40
when i debug first time , the window shows the area is -56116.4
when i debug second time, it shows -7.19607e-35
oh!!my god!!
whats happen?
as i know, the right count is 251.32232
someone help me plz!
|
|
|
|
|
#include <iostream>
using namespace std;
#define PI 3.141529
void main()
{
float radius;
cout << "Plz input the radius:\n";
cin >> radius;
float area = 2*radius*PI;
cout << "The area is " << area << endl;
}
Best wishes
Nuri
|
|
|
|
|
Why do you calculate the area before asking the radius to the user ? Of course it doesn't work because your radius variable is not initialized properly...
|
|
|
|
|
In this universe, the area of circle is calculated r^2*pi and not 2*r*pi .
I can't believe nobody screamed yet
|
|
|
|
|
As long as radius is 2, what's the big deal?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Smartass
|
|
|
|
|
Oh yes, the other error was so obvious that I totally missed that
|
|
|
|
|
I have a printer driver that implements various Drv... functions, like DrvStartDoc, DrvBitBlt, etc. I want it to implement DrvLoadFontFile also, but that function never gets called, even when I print files from Adobe PDF Reader where I know have embedded fonts. What do I need to so DrvLoadFontFile gets called?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Hello,
I used GetCaretPos() to get the caret/cursor position in the CRichEditCtrl box but I am not getting the proper position.
When the cursor is placed before the first character in the text and I
write the following code
CPoint Charpoint;
GetCaretPos(Charpoint);
The answer is
Charpoint.x = 8 Charpoint.y=0;
whereas Charpoint.x = 1 should be the answer
Which other function should I use.
Regards,
Pritha
|
|
|
|
|
Well, the Caret and the Cursor are two different things. The cursor is moved with the mouse, and the Caret is changed by (eg) the edit control. It will typically be a flashing vertical line. Where is *it*?
You may have just clicked in the control and given it the focus. You'd need to click again to get the caret where the mouse is.
Lastly, if it's before the 1st char, I'd expect x = 0 myself. But the reply is in pixels, not chars, so maybe there's an 8 pixel wide margin?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
prithaa wrote: whereas Charpoint.x = 1 should be the answer
Nope. You should read the documentation[^] before using a function you don't know. As specified in the doc, the function returns the client coordinates of the caret pos (so, a "screen" position, not a character index).
You have to use the CharFromPos[^] function to convert the position into a character index.
|
|
|
|
|
|
Hello,
I am writing my question here since it was a continuation of the earlier question.
I found that there is no function CharFromPos() in CRichEditCtrl but I used the notification WM_CHARFROMPOS and got the character position.
I have a n CRichEditCtrl boxes on screen but not all boxes show the character position as 1 when the box receives focus.But actually the character position is 1. The following is the code in the OnSetFocus() of the class derived from CRichEditCtrl.
void CRICH::OnSetFocus(CWnd* pOldWnd)
{
CPoint CharPoint ;
CharPoint = GetCaretPos();
POINTL A; A.x = CharPoint.x; A.y = CharPoint.y;
int result = SendMessage(EM_CHARFROMPOS,(WPARAM)0,(LPARAM)
&A);
int charpos = LOWORD(result);
CRichEditCtrl::OnSetFocus(pOldWnd);
}
What must be the problem ?
Thanks for your guidance
Pritha
|
|
|
|
|
Hi friends, I am trying linking a static library build with gcc (libjulius and libsent) with my code in c++ using vc++, I have made some tests.
I create an .a library with gcc, called fatorial.a and their include (fatorial.h) in a folder include so I create a main.c which call a function fatorial(int) which exists in file fatorial.h and their implementation in fatorial.a, so I can compile with cl like this:
cl /Iinclude main.c \link include\fatorial.a
this works fine.
Now with libjulius and libsent I have one folder called julius4 whose structure is showed below
the statics libraries is
julius4\libjulius\libjulius.a
julius4\libsent\ilbsent.a
theirs include are in
julius4\libjulius\include
julius4\libsent\include
there is an file julius4\libjulius\libjulius-config that when run with argument --libs return the requeried libs
and another julius4\libsent\libsent-config with the same objective, this libs are the libs which exists in libjulius.a and libsent.a respectively, when I run that scripts this returns -ljulius -lpthread -lsent -lwinmm -liconf -lm (-l is the option to search for the library in gcc).
so to compile my code main.cpp with gcc I call it like this:
gcc -Ijulius4\libjulius\include -Ijulius4\libsent\include main.c -o main.exe -Ljulius4\libjulius -Ljulius4\libsent -ljulius -lpthread -lsent -lwinmm -liconf -lm
and this works trying to map to cl I run like this
cl /Ijulius4\libjulius\include /Ijulius4\libsent\include main.c -o main.exe \link julius4\libjulius\libjulius.a julius4\libsent\libsent.a /DEFALTLIB:julius /DEFALTLIB:pthread /DEFALTLIB:sent /DEFALTLIB:winmm /DEFALTLIB:iconf /DEFALTLIB:m
but this find only the lib winmm and can not find iconf.lib m.lib...
Can anyone help me? Thanks.
|
|
|
|
|
- Use "/link" rather than "\link"
- Don't bother using /defaultlib (even if you had spelt it correctly). Just list them on the command-line after the /link with their full names. The standard unix linker does a bit of magic when you use
-llibrary-name - it adds 'lib' to the front of the library-name and '.a' as a suffix, so -ljulius is the same as adding libjulius.a to the command-line.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|