|
From: JoeC on 4 Jul 2008 01:38 I have created a binary graphics type and I save them as binary files. I can load those files in my graphics constructor but I would like to load them as resources. The data in the file is first the number of graphics (int) then a vector or an array of the data of BYTE types. How do I read the resource then take the data from the resource and put it right places in my object. This is how I save the data: void graphic::save(std::ofstream& f){ f.write((char*)&number, sizeof(int)); for(int lp = 0; lp != (size * number); lp++){ f.write((char*)&bitData[lp], sizeof(BYTE)); } }
From: Grzegorz Wróbel on 4 Jul 2008 05:54 JoeC wrote: > I have created a binary graphics type and I save them as binary > files. I can load those files in my graphics constructor but I would > like to load them as resources. The data in the file is first the > number of graphics (int) then a vector or an array of the data of BYTE > types. > > How do I read the resource then take the data from the resource and Something like: void* p = NULL; HRSRC hRes = FindResource(hInstance,MAKEINTRESOURCE(IDR_BIN1),TEXT("BINARY")); if(hRes){ HGLOBAL hglob = LoadResource(hInstance,hRes); if(hglob) p = LockResource(hglob); } p should point to your binary data now -- Grzegorz Wr�bel 677265676F727940346E6575726F6E732E636F6D
From: JoeC on 4 Jul 2008 08:38 On Jul 4, 4:54 am, Grzegorz Wróbel </dev/n...(a)localhost.localdomain> wrote: > JoeC wrote: > > I have created a binary graphics type and I save them as binary > > files. I can load those files in my graphics constructor but I would > > like to load them as resources. The data in the file is first the > > number of graphics (int) then a vector or an array of the data of BYTE > > types. > > > How do I read the resource then take the data from the resource and > > Something like: > > void* p = NULL; > HRSRC hRes = > FindResource(hInstance,MAKEINTRESOURCE(IDR_BIN1),TEXT("BINARY")); > if(hRes){ > HGLOBAL hglob = LoadResource(hInstance,hRes); > if(hglob) > p = LockResource(hglob); > > } > > p should point to your binary data now > > -- > Grzegorz Wróbel > 677265676F727940346E6575726F6E732E636F6D Thanks that is all very useful, now I have to figure out how to write the scrips for all this. I have my resource file: #define IDR_BINTYPE 500 .rc: IDR_BINTYPE BINTYPE "pointer.bin" This is in my main function: point = new graphic(IDR_BINTYPE, hinstance); and it says that IDR_BINYTPE 36 C:\Documents and Settings\Work\My Documents\C++\makeGr\main.cpp `IDR_BINTYPE' undeclared (first use this function)
From: JoeC on 4 Jul 2008 08:51 On Jul 4, 4:54 am, Grzegorz Wróbel </dev/n...(a)localhost.localdomain> wrote: > JoeC wrote: > > I have created a binary graphics type and I save them as binary > > files. I can load those files in my graphics constructor but I would > > like to load them as resources. The data in the file is first the > > number of graphics (int) then a vector or an array of the data of BYTE > > types. > > > How do I read the resource then take the data from the resource and > > Something like: > > void* p = NULL; > HRSRC hRes = > FindResource(hInstance,MAKEINTRESOURCE(IDR_BIN1),TEXT("BINARY")); > if(hRes){ > HGLOBAL hglob = LoadResource(hInstance,hRes); > if(hglob) > p = LockResource(hglob); > > } > > p should point to your binary data now > > -- > Grzegorz Wróbel > 677265676F727940346E6575726F6E732E636F6D I am trying to work with the code I don't have good resources on how to do what I am trying to do. so p points to the data, how do I copy the data in p to my two variables int end (used to count the number of data elements and BYTE the data elements that go into a vector.
From: Grzegorz Wróbel on 4 Jul 2008 18:55 JoeC wrote: > > I am trying to work with the code I don't have good resources on how > to do what I am trying to do. so p points to the data, how do I copy > the data in p to my two variables > int end (used to count the number of data elements and > BYTE the data elements that go into a vector. However you like. You can use memcpy, you can cast void pointer p to pointer of any type you wish and and then either use index operator with it or dereference it. What's the problem? You don't know how to use pointers? -- Grzegorz Wr�bel 677265676F727940346E6575726F6E732E636F6D
|
Next
|
Last
Pages: 1 2 Prev: Basic question about resources/ Next: Time measurement problem during task switching |