|
rajugis wrote: Getpixel and setpixel methods are too slow
Too slow for what? Please explain what you are trying to achieve.
rajugis wrote: and plz give me one samples
We have no idea what you are trying to achieve, nor what you have tried. Be specific about which part of your program does not work.
|
|
|
|
|
I have one image file ..which contains the buildings i want to cut top of left corner building ..
before that i have read image in pixel - by - pixel so that its very slow ..
~~~~~~~~~~~~~Raju~~~~~~~~~~~~~
|
|
|
|
|
What is the criteria to cut/crop the image?
Seems to be a hassle to look for pixels details to do that ?
This signature was proudly tested on animals.
|
|
|
|
|
just check the below links, i think you are looking for these things
CImage with Performance[^]
and one more, more info about cropping and cutting CxImage[^]
Величие не Бога может быть недооценена.
|
|
|
|
|
|
Hmm guys,is it possible to display number1+ number2+number3?
Eg,if a program prompts a user to input 3 numbers,N1,N2 and N3,is it possible for the program to display N1+N2+N3?As far as i know,we can use a while loop to straight away give us the final answer for N1+N2+N3.
To make it clear,if i input 5 as N1,10 as N2 and 15 as N3,can we make the program display
"total=5+10+15=30" instead of "total=30"?
Can someone guide me on this. xD
modified on Friday, September 11, 2009 10:31 AM
|
|
|
|
|
|
UKM_Student wrote: Im currently writing a program which prompts the computer to calculate the sum of even integers between 2 numbers,namely Number_1 and Number_2.Anyone can help me with this?
Yes, lots of people but they may want to be paid for the effort. This is your program so you must at least try and make a start on it. Have you read this[^], especially point 2?
|
|
|
|
|
Ok this is what i have tried so far since 2.5 hours ago...and failed >.<
#include<iostream>
using namespace std;
int main()
{
cout<<"c. The total sum of even integers between "<<firstNum<<" and "<<secondNum<<" is : ";
int total=0;
if(firstNum%2==0)
do
{
total=total+firstNum+2;
cout<<total;
firstNum=firstNum+2;
}while(firstNum<secondNum);
PS i chose the if(firstNum%2==0) to show that if the 1st value is an even number,that loop is to be executed.For The part where the first integer is an odd number,i should be able to write that program after you guys can help me solve the even number part
modified on Friday, September 11, 2009 8:08 AM
|
|
|
|
|
|
And what is your doubt?
(while statement knowledge should be enough for the task).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
the doubt is i can't seem to execute the program >.<
Eg,if i put number1 as 2 and number2 as 10,instead of showing the value of 18,ie.(4+6+8),it shows 4101828
|
|
|
|
|
Your (revised) code
#include <iostream>
using namespace std;
int main()
{
int firstNum = 2, secondNum = 10;
int k;
int total = 0;
k = firstNum + 1;
if (k % 2 == 1) k++;
while (k < secondNum)
{
total = total + k;
k += 2;
}
cout << "c. The total sum of even integers between " << firstNum << " and " << secondNum << " is : " << total;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Erm thanks but do u mind explaining the part where u said
if (k % 2 == 1) k++;???
And i thought that "if statement" needs to be paired with an "else"?
|
|
|
|
|
UKM_Student wrote: if (k % 2 == 1) k++;???
if k is odd (an odd number modulus 2 gives 1 ) then increment k (i.e. k=k+1 ) to make it even.
(Just in case firstNum is odd).
UKM_Student wrote: And i thought that "if statement" needs to be paired with an "else"?
Actually the else clause is optional in the if statement, see, for instance, here.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Erm it says that "If the value of expression is nonzero, statement1 is executed. If the optional else is present, statement2 is executed if the value of expression is zero."
So what happens if the value of expression is zero and the optional else is NOT present?Will the compiler even able to compile it?Or will the compiler able to compile it but instead execute the If statement?Or nothing happens at all?
Oh and thanks for your help.
|
|
|
|
|
And i got another question if u are free to help >.<
I nid to display number 1-10 and their squares.I managed to display the 1-10 part but couldn't display their squares >.<.The output should be smth like this
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
This is what i got so far xD
cout<<"d. Display the numbers 1-10 and their squares."<<endl;
int integer=1;
while(integer<=10)
{
cout<<integer<<endl;
integer++;
}
|
|
|
|
|
Well, you know, squaring a number means multiplying it by itself...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ya i know that,but what i wanna ask is how do i put it next to the integer?I looked at the preview and the numbers 4 and 16,5 and 25 are quite close.What i wanted to do was to put them far apart,yet at the same line at each other....
|
|
|
|
|
#include <iostream>
using namespace std;
int main()
{
int i;
for (i=1; i<=10; i++)
{
cout.width(8);
cout << i;
cout.width(8);
cout << i*i << endl;
}
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Heh i suppose that is a for statement?I did check my books but my lecturer asks us to only use while statements :P
Anyway i managed to output is by writing cout<
|
|
|
|
|
UKM_Student wrote: cout<<integer<<endl;< blockquote="">
Why can't you just add another variable/calculation to the output stream, something like:
cout << integer << ' ' << integer*5 << endl;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
THANKS,didn't know it was that easy LOL :P
|
|
|
|
|
You don't have a statemnt that calculates the square of the number, let alone one that prints it.
I think you may find it better to get hold of a teaching aid and work through the examples therein. Take a look on Amazon, Safari, Google etc and find an introductory C++ book to work through. That is likely to give you a much better grounding in the basics.
I would also recommend "The C Programming Language" by Kernighan & Ritchie. Although applying only to the C, rather than C++ language, it is a superb reference work for someone as new as you, and covers all the basics in fairly simple language.
|
|
|
|
|
Some examples:
int a=5;
if ( a > 10 )
{
a = a-10;
}
else
{
a = a + 1;
}
a = a + 2;
Since a is not greater than 10 then the else block content (namely a = a + 1; ) is executed , and, afterwards the a = a + 2; statement sets the a final value to 8.
int a=5;
if ( a > 10 )
{
a = a-10;
}
a = a + 2;
Since a is not greater than 10 and NO else block is present, the execution reaches immediately the a = a + 2; statement, giving 7 as a final value.
And yes the compiler is smart enough to compile the 'missing-else-clause' if statement.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|