# new model format (1prob, cant copy image file code)

## Recommended Posts

hello, im making my own model format for my games and for others to use, the idea is to have the vertex/face data in the same file as the texture image. the model/texture file would be opened, wertex/face data extacted the rest(image data) writen to a temp file that would then be used to create the texture. OK the probs is that i copy the image code, using while(fin.get(ch)) fout << ch; this works but can only copy some characters ie .. it hits a character it can copy then kills the while, i have tryed some other ways of getting thn writing but most stop at " " <-- white space! .. all others stop when thy hit unusual chars. MY REQUEST: if u know a way of copying bmp file content pls post otherwise if u have any sugestions ,ways u might try then pls post... i will now try getting the int value of each char just like keys[256] but dont think that will work ither, otherwise ill havto read throght the complex functions of <stdio> ... sos for the long mail... pls post ... thnx

##### Share on other sites
stop looking at this and not replying,
just make sum sugestions pls pls pls

##### Share on other sites
// 1° open in binary mode so special "end of file" characters do// not stop you from readingifstream fin( inputFileName, ios::binary );// 2° Find the size and start offset of the bitmap in your filesize_t size = ...fin.seekg( ... )// 3° Read the data from the file to a bufferchar* data = new char[size];fin.read( data, size );// 4° Do something with the buffer// 5° Delete the bufferdelete[] data;

By "do something", I mean either to write the data to a file (using the symmetrical operations "ios::binary" and ".write") or to directly create a texture from memory if you have the API functions to do so.

##### Share on other sites
hey,
i got it incase any1 has this prob some other time an easy way to copy bmp or any other file that contains eof chars or other system chars:

ifstream fin(input_File_Name, ios::binary );
ofstream fout(output_File_Name, ios::binary );

if (fin && fout)
while (!fin.eof())
{
fin.get(ch);
if (!fin.eof()) fout << ch;
}
fin.close();
fout.close();

easy.. :+Pd+:

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628301
• Total Posts
2981906

• 9
• 11
• 11
• 10
• 10