|
Hello there,
I have already used DirectX.Capture to preview what my web cam sees on a panel in my form.
Now I need to somehow transmit this to a client through the network. All I now about
network programming, is that I can only send byte arrays to the client. Any ideas on how
I will get that?
|
|
|
|
|
Chandrias wrote: All I now about
network programming, is that I can only send byte arrays to the client. Any ideas on how
I will get that?
Then you need to send arrays of bytes which represent the pixels in the frames of video.
If your available bandwidth isn't able to handle the number of bytes-per-second required
to transmit the given video dimensions and frame rate, then you'll need to compress the video
somehow. The Video Compression Manager[^] or the Windows Media Format SDK[^] are two
possible solutions for compressing/decompressing video. There's also lots of 3rd party video
codecs.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How to check in C# if directx is installed and which version of it?
|
|
|
|
|
By checking in the registry, there are entries for DirectX version, etc.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
|
dapa wrote: Hello! I need the sample of code of "warp mode image transformation" in photoshop.
http://en.wikipedia.org/wiki/Spline_interpolation[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."
|
|
|
|
|
|
Thank you, Y will to try to do it
|
|
|
|
|
As the subject says I'm looking for an algorithm to scan an image and extract the rectagles that have the same pixel color.
Thanks in advance.
modified on Monday, April 14, 2008 11:44 AM
|
|
|
|
|
Hi,
first of all we have a "math and algo" forum, you should ask there.
I don't know of any official algorithm that matches your request, but it sounds fairly
simple to me; here is some pseudo-code:
rectCollection=empty;
foreach (point P in image and not in rectCollection) {
w=number of identically colored points to the right of P
h=number of identically colored points below P
check rectangle at P with size (w,h) has homogeneous color
if so, add to rectCollection
if not, reduce w and or h based on the position of the first non-matching point
}
done!
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
This could work Luc, thank you, but it looks very inefficient. I have to do this at least twice every second.
|
|
|
|
|
Hi,
there may be better algorithms, it probably depends on the kind of image you are dealing with.
what is the image size?
make sure you use pointers, don't rely on Bitmap.GetPixel, that is way too slow.
are the consecutive images similar?
do the rectangles found have a good chance of being there again on the next image?
if so, make use of it!
you do realize there is no single solution to your problem? if you have
AA
AB
then you can describe it as:
1) A A
A B
2) AAA
A B
3) A A
A
A B
It might help if you describe the intended application a bit...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
modified on Tuesday, April 15, 2008 8:05 PM
|
|
|
|
|
My friend and I were having an argument about the drawing speed of GDI+. First he presented the flicker problem, but I fixed that with
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
then, after awhile, he presented the following:
<br />
using System;<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
using System.Runtime.InteropServices;<br />
using System.Windows.Forms;<br />
<br />
namespace SlowGdi {<br />
public partial class SlowGdiForm : Form {<br />
<br />
private Random RandomSource = new Random();<br />
<br />
private int[] RandomPixels = new int[512 * 512];<br />
<br />
private Bitmap RandomBitmap = new Bitmap(512, 512);<br />
<br />
public SlowGdiForm()<br />
{<br />
InitializeComponent();<br />
this.Disposed += (sender, e) => this.RandomBitmap.Dispose();<br />
Application.Idle += (sender, e) => this.Invalidate();<br />
}<br />
<br />
private void SlowGdiForm_Paint(object sender, PaintEventArgs e)<br />
{<br />
for (int i = 0; i < RandomPixels.Length; i++) {<br />
this.RandomPixels[i] = this.RandomSource.Next();<br />
}<br />
var Locked = this.RandomBitmap.LockBits(new Rectangle(0, 0, 512, 512), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb);<br />
Marshal.Copy(this.RandomPixels, 0, Locked.Scan0, 512 * 512);<br />
this.RandomBitmap.UnlockBits(Locked);<br />
e.Graphics.DrawImage(this.RandomBitmap, 0, 0, 512, 512);
}<br />
<br />
private void SlowGdiForm_Load(object sender, EventArgs e)<br />
{<br />
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);<br />
}<br />
}<br />
}<br />
<br />
This looks all cool, but do a quick Ctrl+Alt+Delete, and notice the 100% Processor Usage (50% on Dual Core)
Anyone have any idea on how to optimise the code to NOT annihilate the processor?
Thanks
- Reelix
P.S: Thread.Sleep(1); helps abit, but not all that much...
P.P.S: Apparently it works perfectly on Vista...
modified on Monday, April 14, 2008 7:58 AM
|
|
|
|
|
Reelix wrote: Application.Idle += (sender, e) => this.Invalidate();
it doesn't matter if you are doing GDI or OpenGL, this will run full out on any machine you are "allowed" to have full access to the CPU. You don't force a redraw on idle you force a redraw on vertical retrace or other unless you do want all the CPU.
|
|
|
|
|
HI ,
i want to do a project on graphics as part of my engineering course .
i have decided to do a project other than game ..i have to use all the basic algorithms and some of the in built functions that are available in turbo C ... please suggest me different topics on which i can do a project .. the code shoudnt exceed 900 lines ...
i have plans to do animation(changing the face with user interface) , simulating towers of hanoii problem ,etc ..suggest me better ideas/topics to do the same
thanks
|
|
|
|
|
Hello..
I have a problem about shading. Actually, I want to apply a phong shading to the 3d object.Here is the code:
#include "Global.h"<br />
#include "lightComponent.h"<br />
<br />
<br />
<br />
<br />
<br />
void setOrthographicProjection() <br />
{<br />
glMatrixMode(GL_PROJECTION);<br />
glPushMatrix();<br />
glLoadIdentity();<br />
gluOrtho2D(0, screen_width, 0, screen_height);<br />
glScalef(1, -1, 1);<br />
glTranslatef(0, -screen_height, 0);<br />
glMatrixMode(GL_MODELVIEW);<br />
} <br />
<br />
<br />
<br />
void resetPerspectiveProjection() <br />
{<br />
glMatrixMode(GL_PROJECTION);<br />
glPopMatrix();<br />
glMatrixMode(GL_MODELVIEW);<br />
}<br />
<br />
<br />
<br />
void renderBitmapString(float x, float y, void *font,char *string)<br />
{<br />
char *c;<br />
<br />
glRasterPos2f(x, y);<br />
for (c=string; *c != '\0'; c++) {<br />
glutBitmapCharacter(font, *c);<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
void Myinit(void) <br />
{<br />
glClearColor (0.0, 0.0, 0.0, 1.0);<br />
glShadeModel (GL_SMOOTH);<br />
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br />
<br />
glMatrixMode(GL_PROJECTION); <br />
glLoadIdentity();<br />
gluPerspective(60,1.0,0.1,100); <br />
glMatrixMode(GL_MODELVIEW);<br />
<br />
<br />
init_light();<br />
<br />
glEnable(GL_LIGHTING);<br />
glEnable(GL_LIGHT0);<br />
glEnable(GL_COLOR_MATERIAL);<br />
<br />
glEnable(GL_DEPTH_TEST);<br />
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
}<br />
<br />
<br />
<br />
void resize (int width, int height)<br />
{<br />
screen_width=width; <br />
screen_height=height; <br />
<br />
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); <br />
glViewport(0,0,screen_width,screen_height); <br />
<br />
glMatrixMode(GL_PROJECTION); <br />
glLoadIdentity(); <br />
gluPerspective(45.0f,(GLfloat)screen_width/(GLfloat)screen_height,1.0f,1000.0f);<br />
<br />
glTranslatef(0.0,0.0,-7.0); <br />
}<br />
<br />
<br />
<br />
<br />
void display(void)<br />
{<br />
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); <br />
glMatrixMode(GL_MODELVIEW); <br />
glLoadIdentity();<br />
<br />
<br />
if ( data_type == 1 )<br />
{<br />
}<br />
<br />
rotate+=1.5;<br />
<br />
glPushMatrix();<br />
glColor3f(1.0,1.0,0.0);<br />
setOrthographicProjection();<br />
glLoadIdentity();<br />
renderBitmapString(10,30,(void *)font,"Display Object From File ");<br />
<br />
resetPerspectiveProjection();<br />
glPopMatrix();<br />
<br />
glFlush(); <br />
glutSwapBuffers(); <br />
}<br />
<br />
<br />
<br />
void processMenuEvents(int option) <br />
{<br />
<br />
}<br />
<br />
<br />
<br />
void create_Menu() <br />
{<br />
<br />
}<br />
<br />
<br />
<br />
int main(int argc, char **argv)<br />
{<br />
glutInit(&argc, argv); <br />
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);<br />
glutInitWindowSize(screen_width,screen_height);<br />
glutInitWindowPosition(0,0);<br />
glutCreateWindow("View Object");<br />
glutDisplayFunc(display);<br />
glutIdleFunc(display);<br />
glutReshapeFunc (resize);<br />
create_Menu();<br />
Myinit();<br />
glutMainLoop();<br />
<br />
return(0); <br />
<br />
}<br />
But, it doesn't work. Can somebody fix my code? 
|
|
|
|
|
It looks like you're just using glutBitmapCharacter to display text? I'm not sure you can get shading to work on a bitmap. What were you expecting to see and what did you actually see? This would help diagnose your problem because I don't think anyone is going to take the time to compile your program and try to reproduce it.
Doing my part to piss off the religious right.
|
|
|
|
|
Tim is correct, you cannot "illuminate" or shade a bitmap text. You can convert the bitmap to a texture, use a texture font drawing routine and it will be illuminated, or you can use stroke fonts. Take a look at the font demo here: http://www.opengl.org/resources/code/samples/glut_examples/examples/examples.html[^]
or here: http://nehe.gamedev.net/lesson.asp?index=03[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."
|
|
|
|
|
I made a control myself with an image as background
(the image is prerendered in the constructor)
when it needs to be repainted (Onpaint event)
it is repainted very slow.
so i want not to repaint the total bitmap,
but only the part that has been invalidated
g.DrawImageUnscaledAndClipped(bmp_background, e.ClipRectangle);
does not work because the origin of the bitmap is drawn at
ClipRectangle.Location
has anyone a solution for it?
|
|
|
|
|
Hi,
Graphics.DrawImage() has some 30 overloads, some of them "Draw the specified portion of the
specified Image at the specified location and with the specified size" and should solve
your problem.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
thanks
sorry for the stupid question
this is something i could have figured out for myself 
|
|
|
|
|
Hello.
I have finished graphical component. It uses GDI+. I understand that I have to dispose unmanaged resources (like Pen, Brush, etc).
But one question arised. How I should dispose global resources?
I`ve decided to use global Pen because this component repaints every 100 ms (but maybe I made wrong decision).
Example of my code:
public partial class MyControl: UserControl
{
Pen myPen;
// constructor
public MyControl
{
...
myPen = new Pen(Color.Blue);
...
}
}
|
|
|
|
|
I don't know C#, but from the looks of your code sample, I don't see anything global, nor
do I see any unmanaged objects.
myPen's existence lasts as long as a MyControl object exists, right?
Am I missing something?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
you should call Dispose on those objects that offer it, as soon as you don't need them
anymore. Creating and disposing GDI objects may be expensive, so it is indeed wise
to avoid these operations in every OnPaint(). So you create them once "globally",
and keep them alive as long as the app lives; that is perfect. On exit, the system
will take care of them (as it always did with resources, even long before .NET came
into this world).
BTW: you don't have the right to dispose of stuff you did not create or ordered created;
this applies to the Pens class, the Brushes class, etc.
So you can replace myPen = new Pen(Color.Blue); by myPen=Pens.Blue;
and not worry about disposing of it at all.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|