|
Save the CImage then.
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]
|
|
|
|
|
plzzz tell me the coding plzzzz
|
|
|
|
|
Could you please post your code? Isn't so clear what you have really done and what you're trying to accomplish.
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]
|
|
|
|
|
Try reading the documentation[^]. Hint: look at the Save method.
It's time for a new signature.
|
|
|
|
|
Here is the code...
//hbm & image are decleared in ChildView class but not initialized in any function...if i have to initialized them ,then how i can initialized them??
HBitmap hbm;CImage image;
//the following code is in OnPaint(); function
CDC *mdc = GetDC ();
HGDIOBJ tmp = mdc->SelectObject(hbm);
mdc->TextOutA (50, 50, Text("Testing"));
image.Attach (hbm);
also tell me tht where i have to put image.Atach();function..i mean in OnPaint(); or in Save function??
//I'm drawing different shapes in OnPaint(); function using
CPaintDC dc(this);
& i want to attach it with CImage so i can save them...
It is a SDI MFC non View/Doc arch. application...Plz tell me in Detail
|
|
|
|
|
I'm not sure of all the steps you need to follow to achieve what you are trying to do, but I would suggest you follow my previous advice and study the CImage class and its members to see what functions are available to create your bitmap and save it to a file. You could also search the articles here on CodeProject and Google for sample code.
[edit]I just saw this article[^] which contains some useful tips.[/edit]
It's time for a new signature.
|
|
|
|
|
i want to know the mistakes in my code... CPallini plzz tell me how i can do that??
|
|
|
|
|
humais wrote: i want to know the mistakes in my code
What code? I have no idea what you are trying to do apart from saving something to do with GDI, for which incidentally, you have been given the answer in a previous thread.
humais wrote: CPallini
Who he?
humais wrote: plzz tell me how i can do that??
The word is please! And you can do whatever it is you need by studying samples and the documentation that I pointed you to earlier (both cases).
It's time for a new signature.
|
|
|
|
|
Hi!
Can we a read a particular line(any line, not from the start or not continuously from a line to the end of the file) at a file using fscanf? I want to discard lines other than that particular line.
|
|
|
|
|
use some logic by reading out some number of lines in order to reach the line you want to get. Keep the number of bytes you read out, fseek() to that position, and use fscanf() there.
modified on Wednesday, July 21, 2010 10:41 AM
|
|
|
|
|
I recommend to just read each line it is, and then check each line until you find the one you want, unless of course as the poster above states, you know how many lines it is in then just fgets until you have reached the required line, but this is not a very good method imo.
while not end of file
parse line
if line is not correct then discard else do some processing on this line
end while
|
|
|
|
|
You cannot.
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]
|
|
|
|
|
Hi,
I have drawn an image on picture control using GDI. I want to crop the image accroding to user selection with a rectangle over the image.
How can I draw a transparent rectangle area over an image?
|
|
|
|
|
Here's an old post of mine describing how to rubberband a line but the idea is basically the same for a rectangle. Rubberbanding[^]
Also have a look at CRectTracker which works nice in this context.
|
|
|
|
|
Look for ROP2 drawing codes in the GDI documentation (function SetROP2()). They do exactly what you want.
Rozis
|
|
|
|
|
Hi!
I've stored my file contents in a Vector of std::string . My file has 55 rows of numbers. I've to get a particular row from the vector. How to do this?
Code:
void CGameMenuPlayerProfileState::setPlayerData(int countryId, int btnId)
{
ifstream myfile("E://Work//Data//playerdata.txt.txt", ios_base::in);
std::string line;
vector<std::string> sets;
vector<std::string>::iterator it = sets.begin();
int player_no = (countryId*11)+btnId;
while(getline(myfile, line))
{
sets.push_back(line);
cout<<line;
}
}
I've to get a particular player data using the int player_no; . i.e I've to get sets[player_no].
How to do?
|
|
|
|
|
T.RATHA KRISHNAN wrote: How to do?
You answered your question yourself:
sets[player_no];
|
|
|
|
|
Firstly, don't go messing round with iterators until after you've filled the collection:
ifstream myfile("E://Work//Data//playerdata.txt.txt");
typedef vector<string> SetColl;
SetColl set;
string line;
while (getline(myfile, line))
{
set.push_back(line);
}
int player_no = (countryId*11)+btnId;
if (player_no < set.size())
{
string player_data = set[player];
}
Steve
|
|
|
|
|
Hi!
It's printing "player_no" value.i.e if contrycode =1 & btnid =1,it will print 11 Not the contents of row corresponting to 11of myfile.I want the contents of the row of myfile corresponting to player_no to be printed.
How to do?
|
|
|
|
|
What's wrong with:
sets[ player_number ]
?
I'm not sure what you're trying to do but if you only want a single row don't read the entire file. If you want player N (and you're using zero based indexing) read and discard the first N and read the (N + 1)th into the string.
Another option is to fix the size of the fields in the file so you can seek to the start of a particular line before doing a read.
Yet another is to create a class that represents each line (presumably player) and implement a constructor that initialises itself from a stream or an overloaded extraction operator.
Cheers,
Ash
|
|
|
|
|
Thanks. It's working. I did a mistake.
|
|
|
|
|
Hi all,
i m working on SDI type application,
i have some data in ListCtrl,in number or rows and column,i want to print this data and see preview for thing printing data.
there is data or row in List may be so large so i shift it and display in multi line,
but still is there is some problem exits.
like some times its not calculate correct no of pages to print,or some times problem in allignment.
i already checked so many articles for printing.
currently i taking help of this article for printing
Another ListView print (preview) sample.[^]
please provide me any sample application or example that perfectly print and preview the list data.
or tell me the better way or printing.
|
|
|
|
|
Hi!
I've got the following exception in my program.
Unhandled exception at 0x005e47c9 in SlogOut3D.exe: 0xC0000005: Access violation writing location 0x006f1b89.
My Code is:
ifstream myfile("E://Work//Data//playerdata.txt.txt", ios_base::in);
char* line = "";
ofstream test("E:\Work\Data\test.txt", ios_base::out);
if(!myfile.is_open())
{
cout<<"Opening File E://Work//Data//playerdata.txt failed"<<endl;
cout<<"ERROR Code:"<<"\t"<<GetLastError()<<endl;
}
if(!test.is_open())
{
cout<<"Opening File E://Work//Data//test.txt failed"<<endl;
cout<<"ERROR Code:"<<"\t"<<GetLastError()<<endl;
}
if(myfile)
{
myfile.getline(line, 1);
cout<<line<<endl;
test.write(line, 1);
}
Call Stack:
> SlogOut3D.exe!std::basic_istream<char,std::char_traits<char> >::getline(char * _Str=0x006f1b89, int _Count=0, char _Delim='
') Line 638 + 0x3 bytes C++
SlogOut3D.exe!std::basic_istream<char,std::char_traits<char> >::getline(char * _Str=0x006f1b89, int _Count=1) Line 596 C++
SlogOut3D.exe!CGameMenuPlayerProfileState::GUIEvent(CGameManager * pManager=0x0012fdb4, const irr::SEvent & event={...}) Line 143 C++
SlogOut3D.exe!CGameManager::OnEvent(const irr::SEvent & event={...}) Line 171 + 0x1d bytes C++
Irrlicht.dll!1000dccf()
[Frames below may be incorrect and/or missing, no symbols loaded for Irrlicht.dll]
Irrlicht.dll!10002d28()
Irrlicht.dll!1000e1b6()
Irrlicht.dll!101325ae()
Irrlicht.dll!101333b3()
shimeng.dll!6c9c4435()
gdi32.dll!763948d9()
user32.dll!760c0979()
opengl32.dll!6d50834f()
user32.dll!760bfd72()
user32.dll!760bfe4a()
user32.dll!760bfdf3()
user32.dll!760c018d()
user32.dll!760b8343()
Irrlicht.dll!10134005()
SlogOut3D.exe!main() Line 24 + 0x25 bytes C++
SlogOut3D.exe!_QueryPerformanceFrequency@4() + 0x347f bytes C++
SlogOut3D.exe!004f7f26()
kernel32.dll!7600d0e9()
ntdll.dll!773b19bb()
ntdll.dll!773b198e()
SlogOut3D.exe!applyAnisotropicFriction() + 0x4f bytes
Irrlicht.dll!10044800()
How to resolve this exception?
|
|
|
|
|
Dump the char* and use std::string instead:
#include "stdafx.h"
#include <tchar.h>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
ifstream ifs("C:\\In.txt");
string line;
while (getline(ifs, line))
{
cout << line << endl;
}
return 0;
}
Steve
|
|
|
|
|
Hi!
getline() expects only a char* not a std::string. IT shows error.
|
|
|
|