C/C++ :: Create Image And Output It As PPM File
Jan 26, 2015
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).
View 1 Replies
ADVERTISEMENT
Nov 18, 2013
Write a program to create an output file containing a customized loan amortization table. Your program will prompt the user to enter the amount borrowed (the principal), the annual interest rate, and the number of payments (n). The payment must be rounded to the nearest cent. After the payment has been rounded to the nearest cent, the program will write to the output file n lines showing how the debt is paid off.
Code:
#include <stdio.h>
#include <math.h>
int main (void) {
[Code].....
View 1 Replies
View Related
Sep 16, 2014
My assignment is use a 3D array to create an image. Use an array of the form arr[300][200][3]. For this homework, you need to use an array of the form arr[3][400][500]. It will have 400 rows and 500 columns. You need to first initialize the array as described in class and after that write the array to a ppm image file. When viewed using Gimp, it should display USM. The letters would be 200 pixels high and 100 pixels wide each. Use at least 15 pixels for the width of the stroke. Use different colors for each letter and a different color for the background.This is what I have so far.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void initialize(unsigned char a[][200][3], int nrows, int ncols, int nc);
void printAll(unsigned char a[][200][3], int nrows, int ncols, int nc);
[code]....
View 3 Replies
View Related
Apr 2, 2013
I am trying to write a program that creates a hybrid image I've hit a roadblock early on my code throws up an unhandled exception I cant find where it goes wrong I need a fresh perspective on this. Here is my code so far
#include <iostream>
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
using namespace cv;
Point P11, P12;
Point P21, P22;
[Code] .....
View 5 Replies
View Related
Jan 27, 2013
how to create, initialize, and maintain a memory device context that works as a local buffer for images? The idea is to maintain some large images in local DCs and bitmaps, and only bitblt them to screen in OnDraw().
What I did so far was was to define CDC and CBitmap objects as members of my View class, and then tried to initialize them with the sequence that begins at "// Initialize buffer". I placed that sequence in either OnInitialUpdate, or PreCreateWindow, or OnPrepareDC, or the view constructor, to no avail. The code always crashes in OnDraw, and I've noticed that the m_hDC member of myDevice is zero at that point.
Obviously, the initialization is wrong and MFC does (too many) things in the background which I'm not aware of.... My question was where can I read about that?
Code:
class CMyView : public CScrollView {
// ...
CDC myDevice;
CBitmap bmp;
CBitmap *oldbmp;
[Code] .....
View 5 Replies
View Related
Nov 21, 2013
how to display an image on the output screen of c++ program.
I am using : Turbo c++(dos box) on win8
View 1 Replies
View Related
Sep 17, 2013
how to insert an image to display in output on c++..
View 3 Replies
View Related
Jul 31, 2014
An ImageList_Create() function (see here) takes 2 parameters: cx and cy which are the width and height of each image.
Everything is good if I know in advance what size my images will have. But what if I don't?
Let's say I select 32x32 and my images are sized as 16x16. What will happen with the image list? Or my images are 48x48 and the image list should grow to accomodate the extra space. Since on Windows image list is just one big bitmap, will the height of the image list shrink/grow to 16/48 or not? Is there a way to test such behavior?
The problem I'm having is to check whether the actual images will be truncated when they are bigger that the image list initial size or not or whether I will see some extra space if the images are smaller.
The closest way I see is this function, but I am not sure its the right one to apply to the image list itself and not to the image inside the list.
How to test this properly and reliably on Windows XP+?
View 3 Replies
View Related
May 21, 2012
I'm wanting to create an image, all I need is to be able to set RGB values and X-Y coordinates, I'm not wanting to read or manipulate images. Any easy to use library or another simple method of doing this?
View 1 Replies
View Related
Jun 27, 2013
i have to create a console based application in c language that can join and split bitmap images. the requirements of the application are as follows :
1. Split Image
Enter number of parts:
Enter source image path:
Enter destination folder:
2. Join Images (all images should be of same width and height)
Enter image path:
Join more Image (y/n):
3. Exit
Take care of following things:
- Application should show number of images processed while running.
- Acceptable Image format is BMP only.
- Application should give all the validations for correct image name, type, size, path, etc.
View 2 Replies
View Related
Apr 10, 2014
I need to create a project that create a automated backup of a file.
i will get the file from C:/Folder/file.exe and move for a other created folder, but.. in every time that user make this backup, a folder will be created with year, month and date, like: C/Folder2/2014/April/16:42/file.exe.
View 4 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 6, 2014
I would like to know if it possible to "run" an image through CMD.In other words i want that image to be opened on CMD.
BTW the image which i am more intrested is GIF files.
View 3 Replies
View Related
Apr 6, 2015
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
");
}
View 12 Replies
View Related
Sep 30, 2013
How to read an image in C++ ...
All what i know that i may use a Cimage library but it doesn't really work or to read the image from a file ....
View 4 Replies
View Related
Jun 3, 2013
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.
View 1 Replies
View Related
Oct 20, 2013
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.
View 4 Replies
View Related
Dec 7, 2014
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();
[Code] .....
View 4 Replies
View Related
Apr 26, 2013
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.
View 2 Replies
View Related
Feb 28, 2015
When reading a PPM Image file, how would I find the magic number and the max color value?
int main() {
string imageFileName;
ifstream image;
imageFileName = "C:UsersDesktopdrink.ppm";
image.open(imageFileName.c_str(), ifstream::binary);
[Code] ....
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?
View 1 Replies
View Related
Feb 5, 2015
I am working on a program which turns a 256 color bmp image to a txt file of a array of 0-255. I wrote this:
#include<iostream>
#include<fstream>
// if 1 , see bmp file header info
#if 1
#define SEE_INFO
#endif
using namespace std;
[Code] ....
Something weird happened. When I use it on simple.bmp (Attachment), it works fine. But when I use it on flower.bmp , it just give me zeros.
Attached File(s)
simple.bmp (3.39K)
simple.txt (8.47K)
flower.bmp (76.05K)
flower.txt (150.49K)
View 3 Replies
View Related
Nov 20, 2014
I have an *.lct file. I like to read *.lct file and save an bmp image.
I can not read this file using usual file read.
Code:
void CLCTtoBMPDlg::OnBnClickedReadlctfile() {
CFileException CFileEx;
CStdioFile ReadFile;
CString OpenlctfilePath;
TCHAR szFilters[]= _T("LCT Files (*.lct)");
CFileDialog fileDlg(TRUE, _T("bmp"), _T("*.lct"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);
[Code]...
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?
View 4 Replies
View Related
Jun 11, 2013
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...
View 6 Replies
View Related
Sep 7, 2014
I'm looking to convert audio, images, video to base64 in c++, and through many searches on the web I've only seem to come up with string > base64.
When I view a .mp3 file for example, there are many characters there that are not available to be used in my string to encode.
[URL] ....
I have this code set up in my project, and all I want is to be able to give the location of any file and have it encode (could just encode to a string, I can handle writing it to a file), and then give a location to put the decoded file as well.
I'm not sure exactly where to even start.
View 6 Replies
View Related
Nov 14, 2012
I have a .png file that my console app reads and puts into a structure that is saved as a file. The png is always the same so I thought I could just add it as a resource image to a resource file so it would be included in my program and not as a separate file. When I did that, the png shows up as a "SystemDrawingBitmap". If I examine this resource in a watch I see "Base" and "Static" members. Expanding those properties does not give me anything useful such as a pointer to the raw png data and its length in bytes.
If worse comes to worse, I can always make a hex dump of the png contents and then put the hex code into a CS file using static initialization.
Surely there is some way I can access the raw data internally and read the bytes into a byte array using C#
View 2 Replies
View Related
Apr 3, 2012
I have this image/video compression project that is to be done in C. I've been given this source code by my supervisor which is supposed to be a working one.
Assuming I have a sequence of 5 images in .pgm format (image41.pgm, image42.pgm .... image45.pgm). Some of the code involved is
Code:
#define START_FRAME 41
#define END_FRAME 45
#define SKIP_FRAME 1
#define INPUT_STRING "/home/folder/image%03d"
int main(){
int frameNo = START_FRAME
nx=1920, ny=1080;
char fileName[128];
[Code] ....
When I tried to compile the code using make file (shell script), I got this error message "In function 'readPgm' format '%d' expects argument of type 'int *', but argument 3 has type 'unsigned char *' "
Can identify what the problem is and how to rectify it?
View 10 Replies
View Related