|
You really need to give more input than that. What is the format of your 'image'? Is that a HBITMAP, or some other data structure? What format should the output file have? Raw/jpg/bmp/gif?
Shatha88 wrote: Can anyone help me :/
Probably not, as it is right now.
|
|
|
|
|
Well
I want to convert the (JPG )image to (0`s & 1`s)text file and
I used this code from internet and gave me this file, but not 0 and 1 also does not draw my picture
#include<iostream>
using namespace std;
#include<stdio.h>
#include<fstream>
#include <cv.h>
#include <highgui.h>
int WritePixelsToFile(IplImage *img,const char *filename)
{
ofstream file;
file.open (filename, ios::out);
if(file==NULL)
{
perror("Unable to open specified file");
return -1;
}
int i,j;
CvScalar s;
CvSize size=cvGetSize(img);
for(i=0;i< size.height;i++)
{
for(j=0;j< size.width;j++)
{
s=cvGet2D(img,i,j);
file << s.val[0];
}
file <<"\n";
}
file.close();
return 1;
}
int main ()
{
char name []= "C:\\file1.txt";
IplImage *imgI = cvLoadImage("C:\\org.jpg");
IplImage *dst = cvCreateImage( cvSize( 30, 30 ), IPL_DEPTH_8U, 1 );
cvCvtColor( imgI, dst, CV_RGB2GRAY );
IplImage *binary= cvCreateImage( cvSize( 30, 30 ), IPL_DEPTH_8U, 1 );
cvThreshold(dst, binary, 150, 255, CV_THRESH_BINARY);
cvSaveImage("C:\\ooo.jpg",binary);
WritePixelsToFile(binary,name );
return 0;
}
the output will be
"
255252253245254252254255241248255255255255255254255249255252255231254255246246255248254255
25323024725523525525522725524921014791656572100127220253217255230252255243242251253232
25524425525124725124925516365042480701035151232251254237255255244255243
25225524423825524321369067000451410200033186251247253255247254255
2532382452532322065221326102167185181182169831667141146255253226255237255
24825525524621000110121233255244249255247246255254142230016126255235249252243
2552552522191653325233244255255255254252252241255250236222681030187254243255251
25524425452218292482422542532402392552552542552462472522552307341217232255240252
24625515831102212532552552552552552552552552482552322552552532204420124245254255
255242553214023825025525525525525525525525524525524225525425325516241039224243255
2502000132624025025525525525525525525525525525425224725524924525524863210169246254
2431406129525525325425525525525525525525525525524924625025424824325515121086255255
2558214016925525524225525525525525525525525525424825024825525524125421001628255255
2555210019625025425525525525525525525525525524825425525025325524625424415023248248
2504710419824625125525525525525525525525525525225525525324824625325225526025239248
2554954208255251244255255255255255255255255255253244255255253255253254008237255
255649251762532552412502552482422522552552552532422552482512552442552170831255255
242113501372522422552542532552552552472472552532482552472402532542491815962255255
255186022422392552472522412422472472522552492492552522552552472442537290142254250
23825314143162249244255255255251246255255236249255252255244250255196150219249245
25123211850492322552342452552552492512542492532442522492182552437412071242255255
2442552081517383254255250236241254248245255251254244255255227119501196245255248
2522492391462100116235255254242255255239252250255245244239125252107255254249238
25524825525510225005719525524025025524825525523425520078140468255238255237249
2542332402552151082301138216823324725524122718795103471252252254255255255
2362552552372552551582503240227484170110141086252252253254255255255
255255253249252251234212107160717061702111059189248255252253254255255255
2462502522512522552552552532191515517180650141223255255244240253253254255255255
238254255251253255253232238230241255255245247255255242240253255255255251253254255255255254
255253255255240225239255255255239248250255252255253247249255251226238247254254255255255254
"
and my picture is image : Black circle ,size = 30 × 30 pixels
can you help me
|
|
|
|
|
Shatha88 wrote: to a file (zero & one)
How do you think your image is stored on the hard disk ? You really think that on your hard disk there's a small image drawn there somewhere ?
Your image is stored as any other file: a bunch of bits.
Could you please elaborate your question ?
|
|
|
|
|
If I have in header file the follow code :
private:
typedef struct ItemData
{
BOOL bState;
LPCTSTR lpszString;
DWORD dwItemData;
ItemData(LPCTSTR lpszString,BOOL bState,DWORD dwItemData);
virtual ~ItemData();
};
and in cpp file I try to use it :
ItemData* pData = new ItemData(lpszString,TRUE,-1);
I get the follow link error :
error LNK2001: unresolved external symbol "public: __thiscall CComboBoxExt::ItemData::ItemData(char const *,int,unsigned long)" (??0ItemData@CComboBoxExt@@QAE@PBDHK@Z)
What I'm doing wrong ?
|
|
|
|
|
You've forgotten to implement functions.
typedef struct ItemData
{
BOOL bState;
LPCTSTR lpszString;
DWORD dwItemData;
ItemData(LPCTSTR lpsz, BOOL bSt, DWORD dw)
: lpszString(lpsz), bState(bSt), dwItemData(dw)
{
}
virtual ~ItemData() { };
};
|
|
|
|
|
You are perfectly right ! Thank you !
|
|
|
|
|
Besides, two things:
1. You forgot to provide the typename for your typedef. Eithr delete that typedef keyword or provide the name after the definition of the struct.
2. Do you intend to add types that are derived from ItemData? If not I advise you to remove the virtual destructor! It will only add to the size of the objects because it has to add a hidden pointer to the virtual function table. Virtual destructors are only neccessary to make sure objects are destroyed properly even when the destructor is called through the interface of a base class. But when you have no inheritance it just adds weight unneccessarily.
|
|
|
|
|
hello guys... Im using waveOutOpen function to play a voice on my Landline number. Now when I play voice in windows media player it plays fine but when I play voice using waveOutOpen() it plays low (actually you"ll have with all attention and no noise around). Wjhat can be the reason. I am using following properties for format for waveInOpen() and waveOutOpen().
WAVEFORMATEX _oFormat;
LPWAVEFORMATEX _pFormat = NULL;
_pFormat = &_oFormat;
_pFormat->wFormatTag = WAVE_FORMAT_PCM;
_pFormat->cbSize = 0;
_pFormat->nChannels = 1;
_pFormat->nBlockAlign = 1;
_pFormat->wBitsPerSample = 8;
_pFormat->nSamplesPerSec = 8000;
_pFormat->nAvgBytesPerSec = 8000;
|
|
|
|
|
Did you check the return value of waveOutOpen is MMSYSERR_NOERROR or not?
--
"Programming is an art that fights back!"
|
|
|
|
|
i am trying to make the folder invisible from the user is there any class id which make the folder invisible please help out of this
thanking you....
|
|
|
|
|
You can use SetFileAttributes()[^] to make a folder hidden.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi, I want to know how this OpenPrinter() API works.
It is returning ERROR_INVALID_PRINTER_NAME if i use this api.
On what basis it is able to tell whether printer name is valid or invalid?
Which registry key it is comparing with?
Thanks in advance.
Regards
msr
|
|
|
|
|
See here[^] for specific details of the name format. You may want to check what parameters you are using in your call.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi,
I need to set the focus to the window that had the focus before my dialog was first selected. To be more precise: as soon as the user clicks a button in my dialog, I want to set the focus to the window that had the focus before the user clicked in my dialog. I also want to be able to realize if that window has been closed in the meantime. What is the best way to achieve that?
Thanks alot for any suggestions.
|
|
|
|
|
hi
store the handle to window for the previous window in memory, recall this hwnd to set focus whenever you want.
"I also want to be able to realize if that window has been closed"
use IsWindowVisible option for this.
Regards,
A. Gopinath.
|
|
|
|
|
Hi, adding to Gopinath's point you can use FindWindow API also. Refer it in msdn.
Regards
msr
|
|
|
|
|
Erik wrote: I want to set the focus to the window that had the focus You can handle the WM_SETFOCUS message. One of its parameters is the handle to the window that has lost the keyboard focus.
Erik wrote: I also want to be able to realize if that window has been closed You can use the IsWindow() function to determine if the window has been closed (i.e., destroyed).
|
|
|
|
|
Hans Dietrich wrote: You can use the IsWindow() function to determine if the window has been closed (i.e., destroyed).
Although this works in the most of the case, it is not "safe": when a window is destroyed its handle becomes invalid and the is ID (the handle value) can be reused by the system for another subsequently created window.
If you don't look at all that while happening, IsWindow may return TRUE, but the window may not be the one you intended.
(I mean: "my name (handle) is the same of my grandfather, I was born after his death, and I live in what it was his house. But I'm not him"! But if you send a letter to him, I'll read it as mine and, hopefully, I can understand the misleading only from the context".)
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Hi,
I am looking for code sample which will explain how to actually pass handles from parent to child process.
I konw:
A child process can inherit handles from its parent process. An inherited handle is valid only in the context of the child process. To enable a child process to inherit open handles from its parent process, use the following steps.
1.Create the handle with the bInheritHandle member of the SECURITY_ATTRIBUTES structure set to TRUE.
2.Create the child process using the CreateProcess function, with the bInheritHandles parameter set to TRUE.
Can someone please share some code sample which would help me understand how to actually use the passed handle in child process.
Thanks in advance!!!
modified on Monday, March 21, 2011 7:13 AM
|
|
|
|
|
Look at the documentation for SetHandleInformation and DuplicateHandle .
|
|
|
|
|
Hi,
I know how it is passed. I want to know how to retrieve and use them in child process. An example will help
Sudhan
|
|
|
|
|
A simple MSDN search yielded this[^].
I must get a clever new signature for 2011.
|
|
|
|
|
I had seen this link. I was wondering how to use it for other type of handles (like mutex, sempahore etc, though they can be retrieved through api like OpenMutex) in child process.
|
|
|
|
|
This issue is specifically about File Handles as far as I know; the other types do not fall into the same category.
I must get a clever new signature for 2011.
|
|
|
|
|
You described how to make the handle available in the child process, but you still need to tell the child the numerical value of the HANDLE . A common way of doing this is to pass the value as a command line parameter.
--Mike--
Dunder-Mifflin, this is Pam.
|
|
|
|