|
Is there a way to find out which ports are open on the local machine and is there a way of opening and closing ports?
|
|
|
|
|
Hi,
What i am trying to do is to create my own color palette with values that i set...for example:
Red will be 00000001
Blue will be 00000011
and so on....
so at the end i can have a BMP or JPG picture created by a binary data that i created...
Is that possible ? anyone knows ?
thank you for your time
-mario
|
|
|
|
|
im looking for an easy way of changing the background of the dialog window to
some tiled bmp image and also replacing the standard button with a bmp
please help me .
|
|
|
|
|
|
I dont want to use any derived classes.
|
|
|
|
|
Take a look on http://www.codeproject.com/cpp/cppforumfaq.asp#ui_bkcolor
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hi.
I using VC++ v.6 and i want to make a program that loads some data from a file and then creates a black and white picture of the data.
Example:
I have a file ("logo.dat") that all it has inside is a logo created by 0's and 1's in a list form that looks like this:
0111110001000100011111000100010001000100 , which actually is :
01111100
01000100
01111100
01000100
01000100
that makes letter A.
Now what i want to do is make the program to load that file and make a B&W BMP or JPG of some dimension that every pixel of the picture represents a 0 or 1 from the file.
It kinda like that programs that takes a picture and makes it in ASCII format in a txt file.
I want to do something like that.
And also reverse the process....like make a JPG or BMP on MSpaint by hand and then the program will make it into 0's and 1's.
I hope i gave a good description of the problem....
Does anyone has any ideas how can this be possible? or where i can get some information about it?
Thank you very much for your time
-mario
|
|
|
|
|
Hi Mario,
perhaps you could use an old function I've written when I've started lerning c
(so the implementation is a little bit more complicated, than it should be)
you only have to create an array which contains your data.
for example:
int x_dim,y_dim
unsigned char* raw;
x_dim=4711; //here insert your width in x-direktion
y_dim=4711; //here insert your width in y-direktion
raw = new unsigned char[x_dim*y_dim];
for(int j=0;j<ydim;j++){
for(int="" i="0;i<xdim;i++){
" raw[i+j*xdim]="//here" you="" must="" decide="" which="" color="" your="" 0="" and="" 1="" should="" have,="" for="" example="" is="" white-="">255, 0is black->0
}
}
then call: raw2bmp(raw,"test.bmp",x_dim,y_dim); and your bitmap should be ready
Hope I could help you
void raw2bmp(unsigned char* raw_data,char* bmp_filename, int xdim, int ydim){
FILE *fp;
int i,j;
fp=fopen(bmp_filename,"wb");
i=xdim*ydim + 4*256 + 54; //Dateilaenge ermitteln
//Datei-Header schreiben
fputc(66,fp);fputc(77,fp); //Magic Number
j=i%256; fputc(j,fp); //Dateilaenge
j=(i%(256*256))/256; fputc(j,fp);
j=(i%(256*256*256))/(256*256); fputc(j,fp);
j=i/(256*256*256); fputc(j,fp);
fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp);//4 reservierte Byts
fputc(54,fp);fputc(4,fp);fputc(0,fp);fputc(0,fp);//Zeiger auf Datenanfang
//Format-Header schreiben
fputc(40,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp);//Format-Header-Laenge
j=xdim%256; fputc(j,fp); //Bildbreite
j=(xdim%(256*256))/256; fputc(j,fp);
j=(xdim%(256*256*256))/(256*256); fputc(j,fp);
j=xdim/(256*256*256); fputc(j,fp);
j=ydim%256; fputc(j,fp); //Bildhoehe
j=(ydim%(256*256))/256; fputc(j,fp);
j=(ydim%(256*256*256))/(256*256); fputc(j,fp);
j=ydim/(256*256*256); fputc(j,fp);
fputc(1,fp);fputc(0,fp); //Anzahl der Ebenen
fputc(8,fp);fputc(0,fp); //Bits pro Pixel
fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //Kompression
i=xdim*ydim;
j=i%256; fputc(j,fp); //Groesse der Pixeldaten
j=(i%(256*256))/256; fputc(j,fp);
j=(i%(256*256*256))/(256*256); fputc(j,fp);
j=i/(256*256*256); fputc(j,fp);
fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //x-Auflösung(in Pixel pro Meter)
fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //y-Auflösung(in Pixel pro Meter)
fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //Anzahl genutzter Farben
fputc(0,fp);fputc(0,fp);fputc(0,fp);fputc(0,fp); //Anzahl wichtiger Farben
//1kB einfuegen jedes mögliche Byte wird dreimal wiederholt und dann ein Nullbyte angefuegt
for(i=0;i<256;i++){fputc(i,fp);fputc(i,fp);fputc(i,fp);fputc(0,fp);}
//Bild an der y-Achse spiegeln: Bild faengt bei bmp links unten an.
for(j=ydim-1;j>=0;j--){
for(i=0;i
|
|
|
|
|
thanks man, i'll look into it ))
|
|
|
|
|
Hi, everyone!
In the following example,
--------
void function(void (*pfunction )(void *))
{
int socket;
//init socket ...
pfunction = functionA;
pfunction ((void*) socket);
}
void functionA (void* InSocket)
{
int socket = (int)(InSocket)
//so some operations
}
--------
I have two questions:
1. I do not know why should we user "void*" as the
parameter list of functionA and not just "int"?
Which way is better? What is the advantage of using
"void*" instead of "int"? Can you show me an example?
2. I have known that we can convert void* to a pointer
type and vice versa. Can we convert void* to a non-pointer
type and vice versa? As shown in this example. What is the
advantage of the usage?
Thanks in advance,
George
|
|
|
|
|
I use void* for windows messages, where you can only pass WPARAM and LPARAM. THis way I can create a pointer to a class with my data using new, and then do my PostMessage(), them I can reinterpret the pointer to the proper datatype, use the data, and delete it when I'm done. Other than that, I never really had a use for it, except when starting threads with AfxBeginThread().
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Thanks, Nitron buddie!
Your experience is valuable to me.
regards,
George
|
|
|
|
|
Hi, everyone!
Suppose there is a static variable in a function, for example,
--------
void FunA()
{
static int a = 1;
if (1 == a)
{
//do operation 1
a = 0;
}
return;
}
--------
The above function FunA is called in a multi thread environment.
I mean each thread calls this function many times.
I think *operation 1* will only be done at the first time when
the FunA is called by a thread. After that, *operation 1*
will not be invoked by other threads.
Am I correct?
Thanks in advance,
George
|
|
|
|
|
That is incorrect. Say two threads call FunA() at about the same time (one after the other). Thread 1 is in the "do operation 1" code when its time slice expires and it is interrupted. Thread 2 then runs and starts executing FunA() as well. It manages to get through the "do operation 1" code and sets a to 0 before it is interrupted. Some time later, Thread 1 gets CPU time again and finishes FunA(), again setting a to 0. So that code block has been executed more than once.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Thanks, Michael buddie!
I think I should define the if block as a
critical region, so that *operation 1* will be
invoked only once.
Am I correct?
Thanks in adavnce,
George
|
|
|
|
|
George2 wrote:
Am I correct?
Yes
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Thanks, Anders buddie!
George
|
|
|
|
|
Suppose we have image file in JPEG format. And after we initialize GDI+, load class Image with constructure Image::Image("image.jpg") .
Suppose I want to do some point processing (image processing, e.g. dithering, histogram, etc.)
So that, we need to access the decoded data, say data bits, of the image.
Data might be represent the color of each pixel in format of R,G,B,R,G,B,.. or divide in to 3 channel, with range 0..255 (char or BYTE ).
How do I can access that data to make some change? or How can I copy it to array of char ?
Could you show me the example?
|
|
|
|
|
Bitmap.LockBits returns a BitmapData object. The BitmapData object's Scan0 property is a pointer to the first scanline of the bitmap data. Be sure to call Bitmap.UnLockBits when you're done.
Bitmap bm;
BitmapData bmdata;
int bmWidth;
int bmHeight;
gdihr=bm.LockBits(new Rect(0,0,bmwidth,bmheight),
ImageLockModeWrite || ImageLockModeRead,
PixelFormat32bppRGB,
bmdata
);
gdihr=bm.UnLockBits(bmdata);
Correct me if you find I'm wrong!
PS:
Forgive me if the syntax is wrong (EX: using "." instead of "->") - I mainly do C# not C++!
Do unto others as you would have them do unto you - Jesus
An eye for an eye only makes the whole world blind - Mahatma Gandhi
|
|
|
|
|
Hi. I have a VERY basic DirectX program from a book and every time i have tried to compile it, i get an unresolved external symbol error on IID_IDirectDraw7. My friend had the same problem with DirectX. I included ddraw.h and ddraw.lib(using the linker), what could possibly be causing the problem?
-- Steve
|
|
|
|
|
Don't remember what I "libbed" for it, but I did a text search for this symbol in all LIB files in DirectX and then tried to link each of returned one by one.
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
I found the problem when searching through a basic DirectX code example on this site. Aparently the book forgot to mention dxguid.lib, which supports the definition of IID_IDirectDraw7.
-- Steve
|
|
|
|
|
I have a large bitmap. I can condense the bitmap's size and
make it display in a dialog, but then the picture is fuzzy.
It's fuzzy before I add it to a bitmap.
I can make the large bitmap appear with scrollbars, but it
doesn't look right.
Is there any way to take a large bitmap and make it appear
naturally and clearly within the dialog? Please any response
any one can give me will be greatly appreciated. Code is
always appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
|
I'm trying to enum all child windows of a given non-null parent window, so I use ::EnumChildWindows . I have defined a callback func BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) and passed it to ::EnumChildWindows as the second parameter.
The problem is that ::EnumChildWindows always returns FALSE and the callback function EnumChildProc never gets called no matter what.
I then call ::GetLastError to check the trouble, but it returns 0, which means "operation completed successfully" is it not? So what gives?
Thanks.
|
|
|
|
|