i try to do nested looping like this
for (i=0;i<=640;i++)
{
for(j=0;j<=640;j++)
{
if(getpixel(j,i)!=0) {
printf("this a color pixel);
}
}
}
but c can't complete this loop and stop in the middle of process why?
memory limitation maybe?
any help to solve?
11 4964
i try to do nested looping like this
for (i=0;i<=640;i++)
{
for(j=0;j<=640;j++)
{
if(getpixel(j,i)!=0) {
printf("this a color pixel);
}
}
}
but c can't complete this loop and stop in the middle of process why?
memory limitation maybe?
any help to solve?
The C graphics resolution is 640 x 480 so you cannot search for pixel at 640,640
Savage
The C graphics resolution is 640 x 480 so you cannot search for pixel at 640,640
Savage
that was not the problem
even i try, eg; (500,500) the problem was still occur
it seems that my borland turbo c 4.5 can't handle to many iteration
if i looping through 500*500 pixel, its equal to 625000 iteration
and my program just escape at the middle without compelete that loop
but if try to decrease the iteration eg(250*125) it can complete succesfully
any suggestion?
Can it handle 320x320?
If it can u can use something like: - for (i=0;i<=320;i++)
-
{
-
for(j=0;j<=320;j++)
-
{
-
if(getpixel(j,i)!=0)
-
{
-
printf("this is a color pixel);
-
}
-
if(getpixel(i+1,j+1)!=0)
-
{
-
printf("this is a color pixel);
-
}
-
}
-
}
If it doesen't than lower it even more.
(And please use code tags ,# button on main toolbar in message window)
Savage
i and j are int right??
and not some smaller type like a short?
i and j are int right??
and not some smaller type like a short?
yes, i & j are int, i can't use short coz it limit to 255
and i want to scan looping through 640*480
i had try 640 * 480 and it was succeded, but was not the best solution
coz i'm using delay() function, to delay beetween loop for 100ms each iteration
so for complete the scanning through whole screen, it takes time about 2 hour
and it's too bad for just one simple program
i try the same program but i convert it to pascal and using turbo pascal to compile it and the result was very good, very fast, turbo pascal just need a couple second to complete the work which borland c took 2 hour to complete it
was the problem in my borland? any suggestion?
Have you tryed my suggestion?
Savage
Have you tryed my suggestion?
Savage
yes, it succeded on 320*320 but took very long time, it took time about 48 minute to complete the loop
That was with delay()?
We need to modify those nested loops.
How about somehing like:
int x[640]; //,this array will store info on x location.
int y[640]; //,respectivly y location
int index=0;//represent array index.
and then: - for (i=0;i<=320;i++)
-
{
-
for(j=0;j<=320;j++)
-
{
-
if(getpixel(j,i)!=0)
-
{
-
x[index]=i;
-
y[index]=j;
-
index++;
-
}
-
if(getpixel(i+1,j+1)!=0)
-
{
-
x[index]=i+1;
-
y[index]=j+1;
-
index++;
-
}
-
}
-
}
And then after the nested loops print those who are colour pixels.
Savage
That was with delay()?
We need to modify those nested loops.
How about somehing like:
int x[640]; //,this array will store info on x location.
int y[640]; //,respectivly y location
int index=0;//represent array index.
and then: - for (i=0;i<=320;i++)
-
{
-
for(j=0;j<=320;j++)
-
{
-
if(getpixel(j,i)!=0)
-
{
-
x[index]=i;
-
y[index]=j;
-
index++;
-
}
-
if(getpixel(i+1,j+1)!=0)
-
{
-
x[index]=i+1;
-
y[index]=j+1;
-
index++;
-
}
-
}
-
}
And then after the nested loops print those who are colour pixels.
Savage
that was without delay
it succeded but there are some value skipped in the looping
e.g: 100,100
101,100
102,100
103,100
109,100 // some value skipped between 104 to 108
and it was happen in random location several time
maybe turbo c had not been optimized for looping?
for the code, i will test ur code suggestion ? and i will tell u the result soon, thank u savage
Whose getpixel() are you calling??
A Windows getpixel() has three arguments one of which is the device context handle. Windows getpixel() produces indeterminate results of the coorindates are outsoide the current clippping region.
Did you set the graphics mode first? If so, what resolution did you set? Are you using the Borland graphics library?
You have an off-by-one error, your for loops should use the < operator instead of <= for the stop condition.
Also, an unsigned char has a maximum value of 255, signed short has a max value of 32767, and unsigned short has a max value of 65535.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: chad |
last post by:
I am writing a program to do some reliability calculations that
require several nested for-loops. However, I believe that as the
models become more complex, the number of required for-loops will...
|
by: Developwebsites |
last post by:
I am taking advanced C++ at college and we use Borland Turbo C++ 4.5 compiler.
How different is Turbo C++ from the standard C++?
I know Borland used to call their versions of C++ and Pascal Turbo,...
|
by: Mountain Bikn' Guy |
last post by:
Take some standard code such as shown below. It simply loops to add up a
series of terms and it produces the correct result.
// sum numbers with a loop
public int DoSumLooping(int iterations)
{...
|
by: scott |
last post by:
I am looking for a copy of Turbo C 1.5 from 1987 for some historical
research I'm doing into computing from that time period.
|
by: Jamie Risk |
last post by:
I'm attempting to improve some serially executing code (that
uses the SerialPort class) bogging Windows down when it runs.
To do the 'antibogging' I'm following the example from MSDN...
|
by: John |
last post by:
I want to understand the usage of _SP in turbo C. Is _SP the stack
pointer register of the CPU? That means _SP should point to the
top of the procedure call stack when we make function calls? I...
|
by: spruce |
last post by:
Hi
Am using Turbo C compiler. Can i create a DLL with this compiler.If so how with an example plz.I tried but not succeeded.Plz help me out of this problem.
Spruce
|
by: Untitled123 |
last post by:
Hey guys!!
I am Planning on Creating a Computer vs. User Chess game involving Artificial Intelligence... by just using TURBO C++
This is NOT impossible!! Please understand that my seniors...
|
by: ashjas |
last post by:
Hello,
I have run this logic on turboc++ 3.0 and it is working fine on it but
its not running on msvs2008 c++.
i am not able to assign the value like this *temp=*main,where main and
temp are char...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |