|
1scouser wrote: I would like to write a program that converts a small text file into a picture file
Can you explain this a little better ? what is the input text ?
anyway, a non-portable solution :
You can use CDC::TextOut or CDC::DrawText to draw to a device context.
After that, you can use CBitmap::CreateCompatibleBitmap to create a bitmap from the device context; and after that, use CImage (from GDI+) to "export" the bitmap object to jpg or bitmap, or whatever format CImage supports.
This signature was proudly tested on animals.
|
|
|
|
|
I just need a program that opens small .txt files created with notepad and also small .jpg pictures. The program then needs to combine the text and pictures into one larger picture file probably a .jpg.
Thanks again!
|
|
|
|
|
1scouser wrote: The program then needs to combine the text and pictures into one larger picture file probably a .jpg.
Yeah but out of context that doesn't mean anything... What are you trying to do exactly ? Sould the text be written on the picture ? If yes, where, and how, and with which font, ...
Do you realize that your question doesn't make a lot of sense ?
You have to explain what you mean by combining text and picture.
|
|
|
|
|
Sorry if my original question was a bit vague. It's been quite a while since I've done any C/C++/MFC programming, in fact VC6. I just need to be pointed in the right direction.
Let me rephrase my question. I have been thinking that instead of converting .txt files and .jpg files into a larger .jpg file, it would be easier if I could convert a single .htm file (obviously containg text and .jpg) into a single .jpg file. Where do I start and what do I need to consider, is this much more difficult than I thought?
Regards
Tony
|
|
|
|
|
It might be more difficult than you thought or perhaps you are not quite sure of what you are trying to do. If you are going to combine a text file with a jpg you will first need to be able to read your text file and your jpg.
I suggest you use google or the CodeProject search facility to find out how to read jpgs (reading a text file should be trivial) and display them.
From there you need to decide what you want to do with your text - put it over the picture like a watermark? Place it above or below like a title? Do you need to be able to move the text around the screen to place it? Are different fonts required? What facilities do you want to be able to add, move, change font/colour/size? Menus, toolbars?
When you have thought about all this and how it might go together then you need to think more about what you then want to do save it as a jpg? Other formats allowed? Save As?
Let us know how you get on - if you have any (more specific) questions I'm sure you'll be helped here by someone!
|
|
|
|
|
You could download Imagemagick, that has all the things you asked for (and much much more), compatible with linux also... It has a simple commandline interface that can be called from yoyr program...
see: http://www.imagemagick.org/Usage/[^]
Rozis...
|
|
|
|
|
hi all,
i have declared a character pointer like this:
char *cHeaderInfo = new char[dwSize + 28 + dwSize1 ];
but while deleting it i am getting assertion failed on this line:
if(cHeaderInfo)
{
delete []cHeaderInfo;
cHeaderInfo=0;
}
it is working fine in 90% cases but failing sometimes, but i am not sure why...so please help me out of this.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
What does the assertion say?
You're probably storing something in cHeaderInfo that is bigger than dwSize + 28 + dwSize1.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
thanx alot superman,
i increase its size and its working fine now......it is what we say a great answer....
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
You should consider using the safe string functions like _tcscpy_s and other C runtime functions that end with _s. Or you must use safe string APIs like StringCchCopy.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Keep in mind that you may have simply masked the problem rather than actually solved it. Find the code that writes to that variable to make sure it is indeed big enough.
"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
|
|
|
|
|
I suspect you've forgotten to add "+1" for the null terminator - looking at your code, it looks like you've added the maximum sizes of constituent strings, but not the '0' at the end.
I would suggest you think about using a string class (std::string or CString) rather than char arrays wherever possible - that way you don't need to worry about managing memory like this.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
here it is the C code , it prints the base filename
I want to modify it to print the following
/work1/data/xxxx/yyy/
const char * path = "/work1/data/xxxx/yyy/file_name.txt";
const char * filename; filename = path+strlen(path);
while (filename != path && *(filename) != '/')
filename--;
if ( filename != path)
filename++;
cout << filename;
|
|
|
|
|
|
it didn't work
I need to print the path without the baseile name
|
|
|
|
|
this logic worked for me perfectly.
const char * path = "/work1/data/xxxx/yyy/file_name.txt";
char path1[256];
strcpy(path1,path);
cout << path <<"\n";
int l=strlen(path);
for(int i=l;i>0;i--)
{
if(path1[i]=='/')
{
path1[i]='\0';
break;
}
}
cout << path1<<"\n";
the output is as you desired.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
sorry,
it didn't work
why?
look at the way you are using strcpy() function
|
|
|
|
|
ksaw123 wrote: look at the way you are using strcpy() function
whats the problem?
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
You don't need to parse. Use SHString apis.
|
|
|
|
|
|
it is C/C++ program not vasuil C++
|
|
|
|
|
Use PathRemoveFileSpec() or _splitpath() .
"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
|
|
|
|
|
Which .h file those functions is in?
|
|
|
|
|
See here.
"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
|
|
|
|
|
my boss
I don't want to use Microsoft C++ , I am using the lagacy C/C++
actually , my code is working but i wanna print the path without the file name as your suggested function.
Thanks
|
|
|
|