I've come to a point where I want to manipulate an image file at run time or with pre-determine sizes and have to be applied when the windows is moved or through in program options.
I know I can do the applying part. However I am a little unsure of how to tackle the image manipulation. I want to make it so that it is not os dependant. So I know I can not rely on any os functions. The only other thought that came to mind was to deal with the video card itself.
So the main question after all of that is said and done. How is c++ able to interact with the video card directly for images? Or if there are existing function I can use. How do they do that? If I can use existing function I would like to be able to manipulate it myself.
How it make it work for my project. Runtime means I am going to have to give the path at the command line?
Here is how I have to run it, so I can test it against the example inputs and outputs they give us to test our program. I am using putty. Already crated the folders inside my project folder, but don't know how to implement it on my source code.
I'm using Visual C++ 6.0 and I'm trying to use fstream to open and read a file that is created only during runtime. This file is written by another function running on another thread, and my program will keep trying to "open" the file until it can be opened, i.e. after it's created, then read 3 numbers from it and execute the rest of its code.
The file test.txt has the content
Code: 1 3 4
My program that polls and opens the file is as follows:
Code: ifstream fin; std::string tfile, snum1, snum2, snum3; long int num2, num3; tfile.assign(argv[1]); printf("Begin prog %s ", tfile.c_str());
[code]....
I executed the program by
Code: test_prog.exe "C: est.txt"
and waited about 3 seconds before putting the test.txt file into C:
My output was
Code: Begin prog C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt fin is open snum1 = num2 = 0 num3 = 0 End of prog
The test.txt file disappears after I refresh the C: folder.
So the values for snum1, num2 and num3 are all wrong, as if the file was not read correctly.
If I put a while fin.good() loop after printf("fin is open "); for that entire block (until printing the values of num2 and num3), then I get
Code: Begin prog C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt Cannot open file C: est.txt fin is open End of prog
How can I correctly read a file that is only created during runtime?
Is it possible to create a program like Robocode, a game controlled at runtime by an external source file in visual c ++? For example create a checkers game where there would be an external source file, read at runtime, which would play automatically, with artificial intelligence. You can? If yes, how?
My assignment is to write a binary calculator that works with floating point for simple math (+,-,x,/). How to do this. the binary numbers need to be from the user.
How I can manipulate certain strings. This program here is supposed to randomly scramble any word/sentence input. However, I notice that even the empty spaces get moved; is there any way to stop that from happening? I would want the empty spaces to stay in their input positions.
I need a translate (in both directions) all primitive types, into char[] (will be stored in string)
I understand how to manipulate integral types with bits and I cant just cut them down and shift them, but float and double don't work with this manipulation. So, how I can create a perfect bit copy of float and double?
int i = 0xFCED03A4; //Random number char c[4]; c[0] = ((i >> 3) & 0xFF); c[1] = ((i >> 2) & 0xFF); c[2] = ((i >> 1) & 0xFF); c[1] = (i & 0xFF);
[Code]...
This is basic stuff but I need an equivalent for float and double types, and it needs to be a perfect BIT copy, not value copy.
here i have an assignment, creating a longInt class and using it to calculate large numbers, i dont have a clue how to manipulate a whole array as a single ineteger.
I'm trying to write a program that manipulates a doubly linked list. My professor wants it to have two structs, one called Node (containing the data, and pointers to the next and previous nodes) and one called DLList, which contains the nodes for the head and tail (which is then passed to all of my functions).
I'm a little confused how to access the head and tail, for instance, if I want to initially set them to null in the main function (he emphasized the need for this), or to use them in my functions. I've tried a lot of variations to call the head and tail, but I keep getting told that head and tail are undeclared in the function.
How might I access my head and tail, for instance in a main function, when they're defined like this? (I took out all of the logic in my functions for clarity)
Essentially what I need to do is take a text file, ("input.txt"):
4 4 1 0 0 1 1 1 1 1 0 0 1 0 0 0 1 0
And take the first two values on line 1 (4, 4) and use them as length and width. Number of rows: 4 Number of columns: 4
Then I need to print out the matrix and further manipulate it. I need to find the sum of the 1's per column and then take that number and replace each 1 with the 1's in each column.
The part that's mostly troubling me is that my instructor will be giving me the input file with random values, so I don't know what the matrix dimensions will be.
I can read the 2D array but can't seem to use it after. I need to find a way to skip the first line, and then read in the matrix and be able to use it mathematically to add up each column.
I made a program that can use a function to manipulate data from a list class. The program is very basic and I think the error makers may be obvious to some of you. I just wanted to find it without having to scrap my program. It doesn't generate a compile error but it announces a memory error while it is running. I use visual studio 2012, the program is an exercise from a c++ book.
list.h #ifndef LIST_H_ #define LIST_H_ typedef double Item; const int MAX = 10; class List
Create an application to manipulate an array of student record objects. A student record will consist of a name (first, middle, and last), an ID number (9 numeric digits, cannot be more or less), an address (street, city, state, and 5 digit Zip code), and a phone number (3 digit area code and 7 digit number). The application will support an array of students. The user will be allowed to enter records from the keyboard, sort records by either name (last, first, middle) or by ID, save the records to a disk file (name supplied by user), and read the records from a disk file (name again supplied by user).
Create a fixed length string that must check that the length of the string is the required length. The fixed length class should be done as a template with the number of characters as the template argument. From this fixed length string, derive a class to hold digits of a fixed length.
Create component classes as necessary to use together to implement the student record class.
Use either the array template created in an earlier lab to handle the array or you may use the vector class from the STL to handle the array of student record objects.
The maximum number of students will be 25 (it may be less).
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)
I have an assignment to manipulate a ppm image which I'm having a lot of difficulty with and I have to have a function to print the ppm but I dont know how to send the ppm file to said function for printing.
#include "transform.h" int print(void){ int i; printf("P6 "); printf("%d %d ", g_width, g_height); printf("22 "); }
This is the first time I'm working with 2d arrays and I have to read the pixels in the input file, then store the pixel from the input image file into the array. And there is a maximum width and height of 500. If the file's too big, then I have to print an error message. Also, my array should only be filled up to the dimensions of the input image file.
I have the code for everything up to that point but I'm not too sure how to approach this. I've defined max_width and height at the top of my file as 500 and I'm thinking of putting this part of the program into a new helper function. But I'm not completely sure how to start, I do know that the array would look something like this though:
int array[max_height][max_width].
1) the syntax of printing the error message/storing the values and 2) the values for my pixels in the input file are all in a single column; each value after the ppm format header is on a new line.
what the input file looks like:
Code: P3 493 401 255 71 0 0 76 4 5 87 11
NOTE: First three lines are the header information for the ppm format; the numbers that follow go like this: red, green, blue, red, green, blue, etc.
I am attempting to read a ppm file. When i do it i try to write it back in another file just to see how's done and i get a terrible result. I assume the problem is something with the casting i do to the variables.
This is my image class
Image:: Image(unsigned int width, unsigned int height, bool interleaved) { buffer = new Component [3*width*height]; this->height=height; this->width=width; this->buffer=Component();
I have an assignment where I have to create an image and output it as a .ppm file. It has to have a black background and have some letters in a different color. My professor told me that my .ppm header should have p3 600 300 255 and P6 600 300 255(what this means, think it sets up the width x height which should be 300 x 600).
This is what I have so far:
#include <iostream> #include <fstream> using namespace std; int main() { struct pixel { unsigned char red;
[Code] ....
Problem in first for loop and what it should look like inside of the for loop, after that I should be able to figure this out... with the fstream (how to output the results in a .ppm file).
I have a jpg file. I have extracted the width and the length of the image. I have done that with some codes and markers. Now I need the image data starts as from that place i would like read the data and print the pixel value. I would like to display the pixels later.
The code gives me seemingly logical integer values for size, width and height. But how would I find the max color value and so called "magic number" for this PPM image file?
Find the attachment. change the file extension *.lct instead of *.txt. I like to read ASCII Data into Hex, Example : Data "A" as "41" (Refer the jpeg image). How is possible?
I'm trying to read from a header file to take the image dimensions and other variables but I don't understand how to iterate through the "key" so it saves each line.
This is what the header file will always look like:
!INTERFILE := !imaging modality := nucmed !version of keys := 3.3 ; !GENERAL DATA :=
[Code].....
Ideally it would just skip the keys that aren't wanted and keep moving through the lines. Should there be a for loop for the key (and if so, how does that work with pointers?) or should this method just be scratched...