|
The Grand Negus wrote: How 'bout them Mandelbrots?
Alive and well, and producing images through infinity.
http://users.erols.com/ziring/mandel.html[^]
http://www.codeproject.com/cpp/mandelbrot_obfuscation.asp[^]
or
void mandel(int xpt, int ypt)<br />
{<br />
long double x=0;<br />
long double y=0;
long double xnew=0;<br />
long double ynew=0;<br />
<br />
for(int k=0;k<=initer;k++)
{<br />
<br />
xnew=x*x-y*y + xpt*pixcorx+Minx;<br />
ynew=2*x*y + Maxy-ypt*pixcory;<br />
x=xnew;<br />
y=ynew;<br />
if ( (x*x+y*y)>4 ) break;
}
<br />
int color = k;<br />
if (color>15) color=color%15;<br />
if (k>=initer)<br />
putpixel(xpt,ypt,0);<br />
else<br />
putpixel(xpt,ypt,color);<br />
<br />
newcolor=color;<br />
}
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I can't thank you enough guys. I really appreciate your help.
thanks for everything.
|
|
|
|
|
Hello frens, help me about how to code for flipping an image horizontally or vertically myself, as a general guide?
I need to do it without using the library functions.
madhav
|
|
|
|
|
The basic idea is to move the data for each pixel from it's original place to its flipped place.
How you code it depends on the layout of your image pixel data.
Typically it's in a packed form (like an array), where pixel data for a row is consecutive and
each row of pixel data follows the previous. To flip the pixels in-place (without needing a
second image buffer) you could use a pointer to the first row/column pixel data and a pointer to
the last row/column pixel data (whether you use row or column depends on if you are flipping
horizontally or vertically)...
Pseudocode for vertical flip:
Set FirstRowPtr to first row pixel data
Set LastRowPointer to last row pixel data
loop (imageheight / 2) times
{
swap FirstRowPtr pixel data with LastRowPointer pixel data
Set FirstRowPtr to next row pixel data
Set LastRowPointer to previous row pixel data
} For interlaced image data it's similar, but the row/col calculations are more complex.
Hope that helps a bit,
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
|
Imagine your image in a mirror reflected in the Y Axis:-
|
0 | 0 | 1 | 1 | 0 | 0
----------|----------
1 | 1 | 0 | 0 | 1 | 1
----------|----------
0 | 0 | 1 | 1 | 0 | 0
|
All we do to achieve this is to negate the X coordinate:-
|
-3,1 | -2,1 | -1,1 | 1,1 | 2,1 | 3,1
-------------------|------------------
-3,2 | -2,2 | -1,2 | 1,2 | 2,2 | 3,2
-------------------|------------------
-3,3 | -2,3 | -1,3 | 1,3 | 2,3 | 3,3
|
But now its in the wrong place so we need to shift it to bring it back:-
SHIFT ---------->>
|
0 | 0 | 1 | 0 | 0 | 1
----------|----------
1 | 1 | 0 | 1 | 1 | 0
----------|----------
0 | 0 | 1 | 0 | 0 | 1
|
So generally we have for an n x m array of pixels reflected in the Y axis (ie horizontal reflection):-
(x,y) -> (-x+n+1,y) (for arrays starting at 0 drop the '+1')
and for the same n x m array of pixels reflected in the X axis (ie vertical reflection):-
(x,y) -> (x,-y+m+1) (for arrays starting at 0 drop the '+1')
Of course this only works for simply defined pixel arrays!
|
|
|
|
|
Hi, i am writing a small app for a WMP Visualization. The app can be downloaded here[^] and the viz can be found here[^].
Can someone please have a look at the code and tell me what's wrong. For starters, i want to render an image in the background then warp it and draw it back to the screen. There are some problems with that. I use RAD C++ for the GUI (http://www.radcpp.com).
Here is some of the code
void Graphics::copyToTexture(WarpFile &wf) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
renderBackground(wf);
glCallList(displayList[DL_TEX_ENABLE]);
glBindTexture(GL_TEXTURE_2D, image);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex2f(0, 0);
glTexCoord2f(0, 0); glVertex2f(0, 512);
glTexCoord2f(1, 0); glVertex2f(512, 512);
glTexCoord2f(1, 1); glVertex2f(512, 0);
glEnd();
glBindTexture(GL_TEXTURE_2D, backTexture);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);
glCallList(displayList[DL_TEX_DISABLE]);
glBindTexture(GL_TEXTURE_2D,0);
SwapBuffers(hdc);
}
It needs to be compiled with Dev-C++, you may need OpenGLUT.dll i forgot to include it in the zip file.
Can someone please help me
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
I would like to help, but you don't say what the problem is. And I don't want to spend an afternoon going through code. Maybe you could say what you expected to obtain and what it is that you are obtaining? Also, I know OpenGL but I don't know what is a WMP.
It seems to me you are trying to draw something and then make OpenGL modify it for you. I'm not sure I understand what you want but in general you already have to have your data ready when you call OpenGL to render a 3D world. OpenGL is the one doing all the drawing (generally speaking) and usually doesn't process (or modify) an already drawn image.
I once made an application to wrap the real-time video feed from a web cam onto a 3D virtual object in the OpenGL world. Do you want to do something like that?
Rilhas
|
|
|
|
|
Rilhas wrote: I once made an application to wrap the real-time video feed from a web cam onto a 3D virtual object in the OpenGL world. Do you want to do something like that?
Pretty much. WMP stands for Windows Media Player and i am making a visualization for it. That is the image that is shown when you play a song. It is a moving image that is rendered in real-time and usually moves to the beat of the song. I want to warp the image i have drawn using a 2D array of warp points. I am currenty making an app that edits those points. When it draws the image, it renders it to a texture then draws quads using the points and maps the a section of the texture to it's respective quad. I then copy the screen (with the warped image) back to that texture and do the whole thing again each frame. The result is that the image has a blur/trace effect where the warped image constantly fades into the background.
Here are some pics http://img519.imageshack.us/img519/1388/viz1kx4.th.png http://img99.imageshack.us/img99/4991/screenshot4kj7.th.jpg
Check out the SwapBuffers post to see my latest problem and see if you can help me their.
Customer in computer shop: "Can you copy the Internet onto this disk for me?"
|
|
|
|
|
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
HDC hdcWindow;
static int nScreenWidth, nScreenHeight;
switch (message)
{
case WM_CREATE:
nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
SetTimer( hwnd,0,2000,NULL);
return 0 ;
case WM_LBUTTONDOWN:
{
HWND tBarHandle= NULL;
return 0;
}
case WM_PAINT:
{
hdc = BeginPaint (hwnd, &ps) ;
hdcWindow = GetWindowDC( hwnd);
HWND hDesktopWnd = GetDesktopWindow();
HDC Source = GetDC(hDesktopWnd);
HDC Destination = CreateCompatibleDC(Source);
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(Source, nScreenWidth, nScreenHeight);
SelectObject(Destination,hCaptureBitmap);
BitBlt(Destination,0,0,nScreenWidth,nScreenHeight, Source, 0, 0, SRCCOPY);
BitBlt(hdc,0,0 , nScreenWidth, nScreenHeight, Source, 0,0, SRCCOPY);
ReleaseDC(hDesktopWnd,Destination);
DeleteDC(Source);
DeleteObject(hCaptureBitmap);
EndPaint (hwnd, &ps) ;
}
return 0 ;
case WM_TIMER:
GetClientRect(hwnd,&rect);
InvalidateRect( hwnd, &rect, true);
return 0;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
How to convert DDB format to DIB format using GETDIBits() function ????
|
|
|
|
|
Something like this maybe...
(warning - I haven't provided for a color table of any kind!! This means this won't work for a
palette-based video mode or a non BI_RGB DIB, which is why I force it to BI_RGB)
int nScreenWidth = ::GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);
HDC Source = ::GetDC(0);
HDC Destination = ::CreateCompatibleDC(Source);
HBITMAP hCaptureBitmap = ::CreateCompatibleBitmap(Source, nScreenWidth, nScreenHeight);
HGDIOBJ hOldBm = ::SelectObject(Destination, hCaptureBitmap);
::BitBlt(Destination,0,0,nScreenWidth,nScreenHeight, Source, 0, 0, SRCCOPY);
::SelectObject(Destination, hOldBm);
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
::GetDIBits(Source, hCaptureBitmap, 0, nScreenHeight, NULL, &bmi, DIB_RGB_COLORS);
bmi.bmiHeader.biCompression = BI_RGB;
BYTE *pPixelBytes = new BYTE[bmi.bmiHeader.biSizeImage];
::GetDIBits(Source, hCaptureBitmap, 0, nScreenHeight, pPixelBytes, &bmi, DIB_RGB_COLORS);
::ReleaseDC(0, Source);
::DeleteDC(Destination);
::DeleteObject(hCaptureBitmap);
delete[] pPixelBytes;
Also make sure you use the correct ReleaseDC/DeleteDC calls on the appropriate DCs.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I have no idea whatsoever about how to start learning how to do graphic designing but i want to get into a career in that field any help or ideas would be nice
|
|
|
|
|
This is a programming forum. By definition, most of us know nothing about graphic design, either. Is that really what you mean ? Or do you mean graphics programming ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: By definition, most of us know nothing about graphic design
well, that's not entirely true.... but I don't know how to direct someone to find the information outside of google. You want, you find, you learn -- that is the only method I ever used. There is a graphics design degree offered at our college, but I doubt he would want to come here.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Can you be more specific.
|
|
|
|
|
Hi,
I want to create a user control which permits to visualize OpenGl inside of it.
How can i do it?
Thx,
Nuno
|
|
|
|
|
|
hi..my program is in C++ with openGL..I have open 1 window to display my objects..but i need to open another window to display the result of processing executed on same object..
my code like this
#include ....
....
routine for processing object(like filter)
....
...
//after that processing i need to open a new window to display results(another image) with keeping the original window open to see diferences.
int main
creat window....
//here the original window of the object before processing it.regards
|
|
|
|
|
Miss_ Petrovna wrote: hi..my program is in C++ with openGL..I have open 1 window to display my objects..but i need to open another window to display the result of processing executed on same object..
http://users.encs.concordia.ca/~grogono/Graphics/examples.html[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Thanks alot ... its very good website .. Petrovna
|
|
|
|
|
When performance is not an issue and when all that we want is just a snapshot of the desktop, we can consider the GDI option. This mechanism is based on the simple principle that the desktop is also a window - that is it has a window Handle (HWND) and a device context (DC). If we can get the device context of the desktop to be captured, we can just blit those contents to our application defined device context in the normal way. And getting the device context of the desktop is pretty straightforward if we know its window handle - which can be achieved through the function GetDesktopWindow(). Thus, the steps involved are:
Acquire the Desktop window handle using the function GetDesktopWindow();
Get the DC of the desktop window using the function GetDC();
Create a compatible DC for the Desktop DC and a compatible bitmap to select into that compatible DC. These can be done using CreateCompatibleDC() and CreateCompatibleBitmap(); selecting the bitmap into our DC can be done with SelectObject();
Whenever you are ready to capture the screen, just blit the contents of the Desktop DC into the created compatible DC - that's all - you are done. The compatible bitmap we created now contains the contents of the screen at the moment of the capture.
Do not forget to release the objects when you are done. Memory is precious (for the other applications).
Void CaptureScreen()
{
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
HWND hDesktopWnd = GetDesktopWindow();
HDC hDesktopDC = GetDC(hDesktopWnd);
HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC,
nScreenWidth, nScreenHeight);
SelectObject(hCaptureDC,hCaptureBitmap);
BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,
hDesktopDC,0,0,SRCCOPY|CAPTUREBLT);
SaveCapturedBitmap(hCaptureBitmap); //Place holder - Put your code
//here to save the captured image to disk
ReleaseDC(hDesktopWnd,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
}
In the above code snippet, the function GetSystemMetrics() returns the screen width when used with SM_CXSCREEN, and returns the screen height when called with SM_CYSCREEN. Refer to the accompanying source code for details of how to save the captured bitmap to the disk and how to send it to the clipboard. Its pretty straightforward. The source code implements the above technique for capturing the screen contents at regular intervals, and creates a movie out of the captured image sequences.
In consideration to the above code please let me know how to capture the network PC`s desktop to my software..
I want to capture it continously i dont want to save it, i want it`s Rectangular Area in ma software...
Please let me know how to do this(of course sockets are used) or create a method for this...
|
|
|
|
|
A process running on the remote system would call CaptureScreen() at regular intervals (however
many frames-per-second you want). Instead of SaveCapturedBitmap(), you would probably want to
SendCapturedBitmap(...). A SendCapturedBitmap() implementaion would transfer the serialized
bitmap bits over a socket to a remotely connected process.
That's the basics but there's some issues...
Getting the bitmap bits. I prefer using DIBSections but GetDIBits() is fine too.
Bandwidth. Multiply the number of bytes per frame by the frames per second. Is it possible to
send that many bytes-per-second over the network without compression?
Which part is giving you trouble? What have you tried so far?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Actually i cant get the main idea how to send on sockets..
void SaveBitmap(char *szFilename,HBITMAP hBitmap)
{
HDC hdc=NULL;
FILE* fp=NULL;
LPVOID pBuf=NULL;
BITMAPINFO bmpInfo;
BITMAPFILEHEADER bmpFileHeader;
do{
hdc=GetDC(NULL);
ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));
bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
GetDIBits(hdc,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS);
if(bmpInfo.bmiHeader.biSizeImage<=0)
bmpInfo.bmiHeader.biSizeImage=bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
if((pBuf=malloc(bmpInfo.bmiHeader.biSizeImage))==NULL)
{
MessageBox(NULL,_T("Unable to Allocate Bitmap Memory"),_T("Error"),MB_OK|MB_ICONERROR);
break;
}
bmpInfo.bmiHeader.biCompression=BI_RGB;
GetDIBits(hdc,hBitmap,0,bmpInfo.bmiHeader.biHeight,pBuf,&bmpInfo,DIB_RGB_COLORS);
if((fp=fopen(szFilename,"wb"))==NULL)
{
MessageBox(NULL,_T("Unable to Create Bitmap File"),_T("Error"),MB_OK|MB_ICONERROR);
break;
}
bmpFileHeader.bfReserved1=0;
bmpFileHeader.bfReserved2=0;
bmpFileHeader.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+bmpInfo.bmiHeader.biSizeImage;
bmpFileHeader.bfType='MB';
bmpFileHeader.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
fwrite(&bmpFileHeader,sizeof(BITMAPFILEHEADER),1,fp);
fwrite(&bmpInfo.bmiHeader,sizeof(BITMAPINFOHEADER),1,fp);
fwrite(pBuf,bmpInfo.bmiHeader.biSizeImage,1,fp);
}while(false);
if(hdc)
ReleaseDC(NULL,hdc);
if(pBuf)
free(pBuf);
if(fp)
fclose(fp);
}
This is the implementation of savebitmap..... and how to sendbitmap i dont know... Please help me.. I want to submit it by 3rd may... else ma 30 numbers would be ruined.
|
|
|
|
|
In theory, you should be able to replace the fwrite() calls with socket send() calls.
In practice, you can improve your protocol by sending the headers only once. This information
only changes if you change the capture rect size or the screen resolution and/or bitdepth changes
so for each captured frame you only need to send the pixel data.
Also, I'm not sure about this calculation:
bmpInfo.bmiHeader.biSizeImage=bmpInfo.bmiHeader.biWidth*abs(bmpInfo.bmiHeader.biHeight)*(bmpInfo.bmiHeader.biBitCount+7)/8;
The pixel data is aligned to a DWORD (4-byte) boundary for each row so maybe something like this:
long lStride = ((bmpInfo.bmiHeader.biWidth * (long)bmpInfo.bmiHeader.biBitCount + 31L) & ~31L) / 8L;
bmpInfo.bmiHeader.biSizeImage = lStride * abs(bmpInfo.bmiHeader.biHeight);
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
HassanKU wrote: In consideration to the above code please let me know how to capture the network PC`s desktop to my software..
Do you have a process running on the remote machine that is capturing its screen and sending it back to the calling machine?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|