|
um...
Ok, i gotta ask: is this like a classic problem that i should know about already, and just immediately recognize?
Or are you just leaving out a lot of details in your description?
Citizen 20.1.01 'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
|
|
|
|
|
I need to capture a video stream from a socket. (Least that is what it appears the requirements are.) Anyone know of sample(s) that can get me started??
Thanks,
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
hi there coders this is George, i've been working on a payroll project and i'm finding difficulty in my c++ console graphics. any one with any idea how to go about it?
you know a class for console graphics or guidelines on how to go about it. i've been seeing some documentation on gotoxy(int x, int y) but i really do not know how to use it.
*
i'm also thinking about how to control my keyboard input. you know stopping the keyboard from appearing on the console and display something simultaneously like ( password -> ********)
*
i've also been seeing some console that are able to create mouse buttons, how do they do that .
Never Underestimate Radical Vision(NURV)
|
|
|
|
|
geocyt wrote: i'm finding difficulty in my c++ console graphics. any one with any idea how to go about it?
Here is an article which designed a class to help you write console apps: Console Enhancements[^]
geocyt wrote: i'm also thinking about how to control my keyboard input. you know stopping the keyboard from appearing on the console and display something simultaneously like ( password -> ********)
In .NET, you can use the Console.ReadKey() method to get a key but not send output to the screen. Here is the MSDN documentation for ReadKey()[^]
So you could write something like this to output "****" to the screen while the user enters the password:
ConsoleKeyInfo keyPress;
keyPress = Console::ReadKey(true);
Console::Write("*");
|
|
|
|
|
Traditionally, you'd use a Curses library (so named because of what you'll spend most of your time doing once you get going with it...)
I've never tried using one on Windows before, but a quick search turns up this: http://pdcurses.sourceforge.net/[^]
Worth a look, maybe...
Citizen 20.1.01 'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
|
|
|
|
|
Shog9 wrote: Traditionally, you'd use a Curses library
real programmers don't curse... they poke.
I had a full library of hand optimized asm code to do text graphics. ahhhh the memories....
Under DOS, text mode memory is useually b800h
http://c.snippets.org/[^]
wputch() commands
_________________________
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."
modified on Thursday, June 19, 2008 2:49 PM
|
|
|
|
|
I remember doin' that with, i think, GWBASIC. Don't know that i've ever tried it under Windows though.
Citizen 20.1.01 'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
|
|
|
|
|
http://cpp.snippets.org/[^] try wputch() 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)
John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."
|
|
|
|
|
How to change specific color with some else color in image.
|
|
|
|
|
read my image processing articles. Iterate over the pixels, and when you find one of the source color, change it to the target color.
OR - you can use an ImageAttributes instance to draw an image and set a color matrix to change the color in one go, I believe.
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 )
|
|
|
|
|
You don't mention the format of your image. In some formats the color data is in each pixel, in others the pixels are an index into a color table. It makes a difference as to which part you search. If the color is in the pixels, unless your image is artificially generated or size of the pixels in color value is small, you're not likely to get many exact matches.
If you don't have the data, you're just another a**hole with an opinion.
|
|
|
|
|
Hi,
I need to write a vc++ program to find the Codec Name of any DirecShow suppoting format video. How can i do that using directshow interfaces and apis?
Apart from DirectShow is there any other api of library which we can use for that.
Thanks in advance.
Kuldeep
|
|
|
|
|
Hi all,
i make one application in which i read the image file of type *.lbl using Bitmap.FromFile(filepath) at that time it will give me an error of "Out of memory".
I know Bitmap supports only BMP ,GIF,JPEG ,PNG ,TIFF. So can any one suggest me what should i do read my own extension (*.lbl) file using Bitmap or any other methode ????
Thanks in advance..
Rana Krishnraj
|
|
|
|
|
Rana Krishnraj,
Well, using the NET Framework class is clearly not going to work because it expects to see a specific, known data format.
If you have your own image file format, (and, of course, we don't know anything about it), you could:
(1) Convert it to a convenient format that your NET Framework bitmap class instance will recognize. I would suggest reading up on the native Win32 Bitmap[^] data structure, and create a valid bitmap (actually, a , DIB, Device Independent Bitmap[^]) in memory.
(2) Write a custom file reader that adequately processes your custom file format.
If you don't know anything about the Bitmap data structure, you should read: Bitmap Storage MSDN[^], or, Storing an Image MSDN[^]
As Feng Yuan says: "The good thing about a DIB is that its storage is managed by the application, so the application can directly access its color table and pixel array, but GDI would not lend a hand to you in setting up a DIB."
|
|
|
|
|
I have series of images very similar to this example image:
http://img258.imageshack.us/img258/2483/exampleep8.gif[^]
As you can see there's empty white space around the text and lines. How can I remove this empty space and crop the image? The red line shows where I want to crop it.
I'm a newbie when it comes to Drawing/GDI+, I appreciate any help.
modified on Wednesday, June 11, 2008 8:25 AM
|
|
|
|
|
Problem solved here's the code:
Bitmap b = new Bitmap(filename);
Rectangle r = new Rectangle();
int topLeft = b.Width, topRight = 0, topUpper = b.Height, topBottom = 0;
string whitePixel = "ffffffff";
for (int y = 1; y < b.Height; y++)
{
for (int x = 1; x < b.Width; x++)
{
if (b.GetPixel(x, y).Name != whitePixel)
{
if (x < topLeft)
topLeft = x;
if (x > topRight)
topRight = x;
if (y < topUpper)
topUpper = y;
if (y > topBottom)
topBottom = y;
}
}
}
r.Location = new Point(topLeft-1, topUpper-1);
r.Size = new Size((topRight - topLeft)+1, (topBottom - topUpper)+1);
Bitmap b2 = b.Clone(r, b.PixelFormat);
b2.Save(newfilename, ImageFormat.Gif);
|
|
|
|
|
Hi,
I am using Video over IP Source filter. I have built a graph.
I wanted to set this video source filters "HostName" to some IP address and connect to that IP address.
Does anyone know "How to set filter property through code without popping up property page"
Thanks
AmolM
|
|
|
|
|
Hi, I have a program that is supposed to blur bitmaps in a Gaussian type fashion.
However, all this does is change the light greys to a yellow-ey colour.
Here is some code:
Functions:
void set_pixel(int x,int y, RGBTRIPLE colour){
image[(bmp.biHeight-1-y)*bmp.biWidth+x] = colour;
}
void get_pixel(int x, int y, RGBTRIPLE colour){
colour = image[(bmp.biHeight-1-y)*bmp.biWidth+x];
}
void avg(RGBTRIPLE colour[], RGBTRIPLE merge, int size) {
for(int i=0; i<size; i++)="" {<br="" mode="hold" /> merge.rgbtBlue += colour[i].rgbtBlue;
merge.rgbtGreen += colour[i].rgbtGreen;
merge.rgbtRed += colour[i].rgbtRed;
}
merge.rgbtBlue = merge.rgbtBlue / size;
merge.rgbtGreen= merge.rgbtGreen / size;
merge.rgbtRed = merge.rgbtRed / size;
}
Implementation:
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x <bmp.biwidth; x="x+3){<br=""" mode="hold" /> for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
}
}
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
}}
Any help you can give would be much appreciated. Thanks
modified on Saturday, June 7, 2008 9:35 PM
|
|
|
|
|
looks messy. My image processing articles here on code project have a Gaussian blur in them.
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 )
|
|
|
|
|
You seem to have had a problem when pasting your code but unless it didn't make it, I don't see where Merge gets zeroed out between calls to avg().
If you don't have the data, you're just another a**hole with an opinion.
|
|
|
|
|
I hadn't put the zeroing of Merge in :S, thanks for pointing that out.
However, this still doesn't solve the problem.
I have also tried zeroing blank between calls of avg(). This didn't help either.
and Christian, I'm checking out your tutorials now, unfortunately I will have to translate them into C++ but I hope it will help.
EDIT: Aha!
I have just done something I realised I should have done before. I tried to create random colours for each pixel, in a noise type function without writing before blurring. I have set these up into 2 seperate projects and now the ouput is a grey screen with some black dots going in lines across the screen :S
Here's a picture of what the output is:
http://s131.photobucket.com/albums/p287/CorporateRock/blurtry.jpg[^]
"Sir, I protest. I am NOT a merry man!"
modified on Sunday, June 8, 2008 8:52 AM
|
|
|
|
|
Ah, I think I see it now. In avg(), Merge is of type RGBTRIPLE. Each color element is an unsigned char which limits its value to 0 to 255. You're adding nine elements into each color value before you take the average. On average, you've overflowed it after the second addition and wrapped around. You need to use a temporary accumulator that's at least an unsigned short but hey, go wild and make it an unsigned int. Then you're covered if you use a bigger kernel than 3x3.
If you don't have the data, you're just another a**hole with an opinion.
|
|
|
|
|
Thanks for the advice .
I used an unsigned int for red green and blue. This still didn't solve the problem, however as it still seems too organised and is tritone. :S
Sorry my code is so messed up.
"Sir, I protest. I am NOT a merry man!"
|
|
|
|
|
Try giving us the latest version. Kind of hard to guess how you've rattled the box.
If you don't have the data, you're just another a**hole with an opinion.
|
|
|
|
|
 Okay, here's the full file(sans the reading/writing stuff)
void set_pixel(long x,long y, RGBTRIPLE colour){
image[(bmp.biHeight-1-y)*bmp.biWidth+x] = colour;
}
void get_pixel(int x, int y, RGBTRIPLE colour){
colour = image[(bmp.biHeight-1-y)*bmp.biWidth+x];
}
void clear_pixel(RGBTRIPLE colour){
colour.rgbtBlue = 0;
colour.rgbtGreen = 0;
colour.rgbtRed = 0;
}
void avg(RGBTRIPLE colour[], RGBTRIPLE merge, int size) {
unsigned int blue = 0, green = 0, red = 0;
for(int i=0; i<size; i++)="" {<br="" mode="hold" /> blue += colour[i].rgbtBlue;
green += colour[i].rgbtGreen;
red += colour[i].rgbtRed;
}
merge.rgbtBlue = blue / size;
merge.rgbtGreen= green / size;
merge.rgbtRed = red / size;
}
<small>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
ZeroMemory (&bmp, sizeof bmp);
bmp.biClrImportant = 0;
bmp.biBitCount = 4;
bmp.biCompression = 0;
bmp.biPlanes = 1;
bmp.biSize = 40;
bmp.biSizeImage = 0;
bmp.biXPelsPerMeter = 0;
bmp.biYPelsPerMeter = 0;
bmp.biClrUsed = 16;
bmp.biHeight = 128;
bmp.biWidth = 128;
long paddedsize = bmp.biHeight * bmp.biWidth;
bfh.bfType = 19778;
bfh.bfReserved1 = 0;
bfh.bfReserved2 = 0;
bfh.bfOffBits = 1078;
bfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + paddedsize;
hfile = CreateFile("noise.bmp",GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_EXISTING,NULL,NULL);
ReadFile(hfile,&bfh,sizeof(bfh),&written,NULL);
ReadFile(hfile,&bmp,sizeof(bmp),&written,NULL);
int imagesize = bmp.biWidth*bmp.biHeight;
image = new RGBTRIPLE[imagesize];
ReadFile(hfile,image,sizeof(RGBTRIPLE),&written,NULL);</small>
RGBTRIPLE blank[9]= { 0 };
RGBTRIPLE Merge = { 0 , 0 , 0 };
long yp=0, xp=0;
for(int y = 0; y < bmp.biHeight; y=y+3){
for(int x = 0; x < bmp.biWidth; x=x+3){
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
get_pixel(x+xp,y+yp,blank[i]);
if(xp<3)
xp++;
else{
xp = 0;
yp++;
} }
avg(blank, Merge, 9);
set_pixel(x,y,Merge);
for(int i = 0; i < 9; i++){
blank[i].rgbtBlue=0;
blank[i].rgbtGreen=0;
blank[i].rgbtRed=0;
}
clear_pixel(Merge);
yp=0, xp=0;
}}
EDIT: AHa! I've found something
for(int i = 0; i < 9; i++){
int yp=0, xp=0;
I declared yp and xp as int when I had already declared them as long. This was reverting them to 0 each time.
Trouble is, get_pixel() and set_pixel() give unhandled exceptions when they use anything other than x and y. I've tried "x=x+xp" but it still happens. Hmm....
I'm stumped.
"Sir, I protest. I am NOT a merry man!"
|
|
|
|
|