C :: Creating PPM Image - Black Rectangle With A Circle
Mar 12, 2013
I'm trying to create a PPM image for a class assignment. A black rectangle with a circle at the point 225, 175 with a radius of 75. I have to use certain specific methods, so I can't use like Bresenham's really famous method for creating a circle.
The problem is that it compiles fine, and transfers to an image fine, but always says that I have a negative or zero image size.
Code:
#include "shapes.h"
int main () {
int i, j, x, y;
fprintf(stdout,"P6 width height 255
");
[Code] ....
And my header is:
Code:
#include <stdio.h>#include <math.h>
#define height 480
#define width 640
#define cy 175
#define cx 225
#define radius 75
The circle has to be filled in. I made it white. Also, i and j are unsused so far, so just ignore them.
View 1 Replies
ADVERTISEMENT
Oct 5, 2013
I want to detect colors that in the black rectangle. [URL] How can I do? What library should I use?
View 7 Replies
View Related
Jul 5, 2013
Write a program using turbo c to draw a rectangle inside a circle..........
View 2 Replies
View Related
Nov 2, 2014
creating a bitmap. Our professor wants us to creat a black 100*100 bitmap.
Code:
#include <stdio.h>
#include <stdlib.h>
#pragma pack(push,2)
typedef struct{
[Code].....
I dont even know where to start. I spend the last 7h infront of my computer and i'm so frustrated cause my professor gave us no information what so ever. At the moment its more of a trial and error process than anything else.
How would i set the color of an individual pixel for examplel or how would i save the file ?
View 1 Replies
View Related
Oct 30, 2013
I'm supposed to print a small rectangle inside concentric circles that are inscribed in a rectangle.I'm not really sure where to start with printing a circle in a ppm file.
View 13 Replies
View Related
Nov 4, 2013
Im supposed to create an to array of eight Circle objects initialized with the following radii: 2.5, 4.0, 1.0, 3.0, 6.0, 5.5, 3.5, 2.0. Then use a bubble sort to arrange the objects in ascending order of radius size before displaying the area of each object.
The error I get is "Cannot open include file: 'Circle.h': No such file or directory". Do I have to create a separate file for it?
#include <iostream>
#include <iomanip>
#include "Circle.h"
using namespace std;
class Circle {
public:
Circle()
[Code] ...
View 1 Replies
View Related
May 13, 2014
Consider I have a rectangle like this:
Point p1(100,100);
Point p2(300,200);
Graph_lib::Rectangle r(p1,p2);
And also I have a function that takes a rectangle and returns a Point of that, say, top-left corner of that rectangle. For example:
Point N(Graph_lib::Rectangle R1);
My question is that, first, how to send that Rectangle r(p1,p2) to the Point N(Graph_lib::Rectangle R1) function? And then, how to return a Point from that function?
My IDE is visual studio 2012.
View 19 Replies
View Related
Dec 3, 2014
Create a script that lets you rotate an image through some number of degrees(out of a maximum of 360 degrees). The script should let you specify that you want to spin the image continuously. It should let you adjust the spin speed dynamically.
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>Final</title>
</head>
<body>
<canvas id = "drawRectangle" width = "200" height = "200"
style = "border: 5px solid black;">
</canvas>
[code]....
View 2 Replies
View Related
Nov 1, 2013
My below code is createing databases(database here is a kd tree) and indexing one image per database. I have two classes LastDatabaseTndexingPolicy and another forwardingDatabaseaccessor.cpp .
I am calling the GetDatabaseToAccess() function from forwardingDatabaseAccessor.cpp class .GetDatabaseToAccess() function is present in LastDatabaseTndexingPolicy class and it returns the database created as a pointer and using that database pointer we call another function which actually indexes the image to the database .
Now my issue is i am not able to have multiple threads act on the following functions as DatabaseAccessor_ptr db which is in the following file is coupled with two functions and however i put locks in the LastDatabaseTndexingPolicy file as below i end up getting synchronization issue ..........
Hence now i am using a single lock in forwardingDatabaseAccessor.cpp and serializing the code,. How can i change my design to parallelize this code .........
In ForwardingDatabaseAccessor.cpp we are calling function from LastDatabaseTndexingPolicy as shown below:-
DatabaseAccessor_ptr db is something which needs to be synchroinized. I tried createing 256 databases with one image each and when i run this code i ended up creating 175 databses and though i was restricting in code with locks that every database has only one image i ended up having two images in single database ..... ideally i had to get only one image per database but i got two images in few of them hence instead of 256 database this code created 175 or so databases.
indexing::IndexReturnValue ForwardDatabaseAccessor::index(cv::Mat image,
const std::string& imageName, features::Camera::Type indexCameraType,
features::Camera::Type recogCameraType) {
DatabaseAccessor_ptr db = this->IndexingPolicy_ptr->GetDBToIndex();
[Code] .....
View 1 Replies
View Related
May 17, 2014
How to make a red and black tree using SFML ....because i really need...I really don't know how to use SFML i only know how to use win32 console.
View 3 Replies
View Related
Dec 8, 2014
Red Black Trees. [URL] .....
My app keeps crashing after about the 49th insert.
I tried debugging and it keeps pointing to this area in the Fixup:
if (z->parent == z->parent->parent->left) {
y = z->parent->parent->right;
View 13 Replies
View Related
Nov 26, 2013
I've been working on my deletion function for Red and Black trees but can't seem to get it to work. From what I can tell, the remove function, instead of deleting the single value that will my prompt by the user, will delete all the values that are in the red and black tree.
Code:
bool RedBlackTree::remove(int x) {
if(!search(x)){
return false;
} else {
Node* z = new Node(x);
rbremove(z);
[Code] ....
View 4 Replies
View Related
Jul 29, 2013
I tried to write a code to calculate black body spectra over an user-entered range of wavelength and temperatures. The equation I'm trying to code is the second one this image (stolen from Wikipedia)The syntax to run it is bbgrid lambda_inic lambda_final temp_inic temp_final inc_T inc_lambda
where bbgrid is the name of the program, lambda_inic and lambda_final are the limits of the wavelenght range (in units of angstroms, 1A=10⁻⁰m), temp_inic and temp_final are the limits of the temperature range (in Kelvins) and inc_T and inc_lambda are the increments. What I want to do is, given the ranges of temperatures and wavelengths, to run the code over the lambdas and the temperatures.
The problem is that the behaviour of the intensities (what I'm calculating) is erratic. Sometimes it is highly positive, sometimes immensely negative and turning between those two. As an example of an output file, I'm getting things like this:
3100 1915076038
3110 -1233496775
3120 1741010116
3130 1229780625
3140 421722788
3150 -1874760945
3160 1654746252
3170 1062468321
3180 -795217626
3190 -1141129750
3200 -1570716956
3210 539385985
While I was trying to debug the code, I found the problem may reside in the exponential factor in the denominator. I wrote some lines to calculate and print on the screen only the exponential, and it was oscillating like crazy. The output file should produce curves like this:
Code:
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
[code]....
View 14 Replies
View Related
Jul 3, 2014
Im trying to compare the image of a button to another image in Visual Studio like so...
//variables
Image active = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\active.png");
Image stunned = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\stunned.png");
[Code]...
btnStatusPlr1.Image SHOULD come back as True.Then I realized it might not be the same as setting the buttons image in the properties (Which is what i did to get the original image (the one being compared to))
I do have a feeling ive done something wrong here (Yes im a noob /> )
Variable active, is the same image as the buttons default (Well should be)
View 1 Replies
View Related
Apr 15, 2014
I'm making this program to mess with people and make them think its a virus.
#define _WIN32_WINNT 0x0500 //For hiding your console
#include <cstdlib>
#include <iostream>
#include <Windows.h>
#include <WinBase.h>
[Code]....
At line 42 and 43 I want to make the cursor move around in a circle over and over again but I'm not sure how.
View 4 Replies
View Related
Mar 22, 2013
I was given an assignment for class to calculate the area of a circle using only the radius as a user input and not using Pi in the code. I need to do this by calculating the areas of a series of rectangles under the curve and adding them together. Using nested loops to continuously reduce the size of these rectangles until the approximated area value is within a margin of error less than 0.1%.
Code:
#include<iostream>
#include<cmath>
using namespace std;
int main ()
[Code] .....
View 7 Replies
View Related
Jul 26, 2014
How can I find each and every pixel in a circle so that I can do some operations on it.
View 6 Replies
View Related
Mar 11, 2014
Found a good beginner's tutorial to learn Visual C++: [URL] ....
How to change the drawing so that instead of squares, the game draws circles. Can figure out that using Ellipse in the code results in circle outlines, but the fill remains as square color shapes.
The drawing code from the tutorial is below. How to substitute filled circles for filled squares.
Code:
// CSameGameView drawing
void CSameGameView::OnDraw(CDC* pDC){
// First get a pointer to the document
CSameGameDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if(!pDoc)
[Code] ....
View 6 Replies
View Related
Jul 3, 2013
Code:
#ifndef CIRCLE_H
#define CIRCLE_H
class Circle {
public:
//constructors
Circle();
Circle(double r);
[code]....
The function isBigger() returns true (or false) if the radius of the Circle instance on which the function is invoked is bigger (or smaller) than the radius of the Circle instance passed to the function.: How to implement this function?
View 5 Replies
View Related
Aug 28, 2014
I installed FLTK 1.3.X (from here [URL] ...) on my visual studio 2012 compiler and use PPP book for programming (this: [URL] ..... ). My problem is about filling a Shape in. For example , this code:
#include <Simple_window.h>
using namespace Graph_lib;
int main() {
Simple_window win(Point(100,100), 1000, 600, "Binary_tree");
Graph_lib::Circle c(Point(200,200),50);
c.set_color(Color::red);
[Code] ....
When I run the program, All three Shapes are drawn but only the Rectangle is filled in! Why?
set_color works for the three and apparently the set_fill_color is defined for all Shapes and it too should work but why it doesn't work for Circle and Ellipse?
This is the .CPP and .h files [URL] ....
View 3 Replies
View Related
Jan 22, 2014
I am drawing a circle using ellipse because there is no explicit command for this.
Code:
pDC->Ellipse(CRect(70, 170, 300, 400));
What is the centre of circle and what is radius in the above command?
View 2 Replies
View Related
Sep 27, 2014
I trying to write a program that calculates the area and circumference of a circle.
This is what I wrote so far.
Code:
#include <stdio.h>
void main()
{
int r;
int pi=3.14159265;
float cir,area;
printf("
enter the radius of the circle ");
[Code]...
the Problem is when I input the radius the answer I get is zero regardless of the the radius. Am I missing something?
View 4 Replies
View Related
Oct 31, 2014
I am working on a computer program where I need to generate points on a circle. I am familiar with this kind of algorithm:
for(d=0; d<=2*pi; d+=0.01)
{
x = cos(d)*radius;
y = sin(d)*radius;
}
However, due to the specifics of the program I am writing, I need to iterate through a fixed number of points one at a time, like so:
for ( int x = 0; x < blockSize; x++ )
{
y = ???
}
This essentially "fixes" one axis of the circle, since I can't do: x=rx+sin(d)*r.
I have tried simply: "y = sin(d)*radius;" and I get a curved shape, but it's not a circle.
My question then is, how do I get the value of y in this situation, where the x axis is incrementing by 1 through a range of values? Is it mathematically possible?
View 6 Replies
View Related
Jan 23, 2014
My problem is the following : We have a circle paper of radius R. We will cut off a sector of this circle (with length rem_sec), and the remaining (bigger part) will create a cone. Radius of cone base is r.
I need to create a code that prompts the user to enter circle's radius R and the program will calculate the length of removed sector (rem_sec) so that the created cone has the Max Volume.
I wrote the following code, but it doesn't work. It displays both rem_sec and MaxV = 0.
#include <iostream>
#include <cmath>
#include <iomanip>
#include <conio.h>
using namespace std;
const double PI = 3.1415;
int main() {
double rem_sec;
[Code] ...
View 5 Replies
View Related
Dec 7, 2014
i would like to make a planet that moves in a circle motion. I dont know how to start and how i can move a "planet" in a circle motion?
View 2 Replies
View Related
Oct 7, 2013
Let (x,y) be the center of the circle. (x,y) will not be (0,0). I have radius of the circle. Now i want to find the angle and radius of the given point inside the circle.
View 2 Replies
View Related