C++ :: Use 3D Array To Create Image

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


ADVERTISEMENT

C++ :: Program To Create Hybrid Image

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

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 View Related

Visual C++ :: How To Create Image Buffer In MFC

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

Visual C++ :: ImageList Create Function - Size Of Image

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

C :: Create Console Based Application That Can Join And Split Bitmap Image

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

C :: Create Function To Create A Dynamic Array That Fill With Randomly Generated Integers From 0 To 50

Oct 26, 2013

I have a struct called Array and I'm to create a function to create a dynamic array that's fill with randomly generated integers from 0 to 50 (inclusive) and a function to destroy the array for freeing its memory. Below the code that I have written so far.

Code:

* Struct */
typedef struct {int *pArray; //the dynamic array
int length; //the size of the dynamic array}Array;
/* Function to create a dynamic array */
Array *initializeArray (int length) {int i;
}

[code]....

View 7 Replies View Related

C :: Read A 24 Bit Image Using 2D Array

Oct 29, 2013

I am trying to read a 24 bit image but I'm getting errors when I'm tryting to read the pixels.

-The reading part looks bad because I'm reading both headers field by field. But I'm sure that it is reading both headers correctly.

-Right now my biggest concern is to get it to read successfully an entire bmp image

I'm using this calculation to get my padding bytes:

padding bytes = [4-(3*width)mod 4]mod 4

When I use a 2x2.bmp file to test it, I get an error that the [1][1] pixel was not read. When I use a bigger image it gives me the same error after about 100 rows and then every pixel is an error from that point on. This is what I got so far:

Code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
const size_t cSizeofPixel = 3; //size of struct tPixel
typedef struct{
unsigned char blue;
unsigned char green;
unsigned char red;

[Code]...

I read this post Reading 24 bit BMP file into a 2d array.

I still don't know if my error is when I allocate memory to my 2d array, or if I'm doing the padding bytes wrong or if it is something else.

View 8 Replies View Related

C :: Reading PPM Image Into 1D Or 2D Array

Apr 4, 2013

I have an assignment where I need to take an assigned image, rotate it 90 degrees to the right, flip it upside down, and turn it to grayscale; each with different outputs.

I was thinking if I can read in the image into a 2d array //array[height][width] or even just an array with the values of each pixel (r, g, b), I can just modify the array and spit it out when done.

if i can just get it into the array, I think I'll be fine. We've done similar assignments with modifying arrays for grayscale images and the other two I can probably figure out. But how am I going to read in each pixel into an array with three different values in each slot? This is my code so far:

Code:
#include<stdio.h>

View 1 Replies View Related

C# :: Compare The Image Of A Button To Another Image In Visual Studio

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

C :: Reading PPM Image Into 2 Dimensional Array

Nov 29, 2014

I'm trying to read a PPM image into an array. The header will have already been read in and I'm trying to put in a 2-d array to make manipulations easier. This is the code I have so far with LOTS of errors and warnings and I honestly don't know what almost any of them mean.

Code:

int imageArray( FILE *input, struct pixel *theArray ){
int i, j;
int col, row;
int *imageArray = (int**)malloc(row * sizeof(int*));
for(i=0; i<row; i++){

[Code]...

View 3 Replies View Related

C++ :: Transform Integer Array To BMP Image

Jun 8, 2013

I have a problem concerning transforming int array into bmp image. I wanted to add a post in this topic: [URL] .... , but unfortunately it is closed. Actually I have a question concerning the code written by Duoas. I have a function which takes values from the file and I want to convert it into bmp with the use of Duoas code. I do it like that(it's Duoas code + my load and main function) Is it something wrong with how I do it or it's rather sth wrong with the file.

It compiles without errors but when I run it: core dumped.

According to gdb debugger problem is here: double hue = (intarray[ row - 1 ][ col ] - min_value) * granularity; programs stops, segmentation fault ...

#ifndef INTARRAY2BMP_HPP
#define INTARRAY2BMP_HPP
#include <fstream>
#include <iostream>
#include <string>

[Code] ....

View 2 Replies View Related

C++ :: Propagation Algorithm - Image To 2D Array

Feb 17, 2015

A few months ago I wrote a simple neural network using back propagation algorithm. It's input is a 2D array of any given size and type. I tried to make it learn the logic functions like AND & OR it worked. So now I want to try image recognition and I need the image as a 2D array of RGB values.(I mean three arrays of course one 2D array for each color.)

How can I get an array of RGB from an image? Can I do it with streams?

View 1 Replies View Related

C++ :: Retrieve The Image From URL And Save It In Array?

Sep 10, 2013

I am trying to retrieve an image from its URL as an array where each box represents the pixel value of the image.

View 3 Replies View Related

C++ :: Program To Read Image (Later Represent By Array 3D)

May 1, 2013

I will make a program to read the image in C++. And later, the image will represent by array 3D, which (x,y) represent the spatial coordinate of (height*weight) image (pixel) and z represent the intesity of those image (0-255).

In matlab, the code for do that is --> imread('image.jpg')

How can I do that in C++?

View 2 Replies View Related

C/C++ :: Convert 256 Color BMP Image To TXT File Of Array Of 0 - 255

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

Visual C++ :: How To Convert PNG Image Into Byte Array

Mar 12, 2013

I m loading a png image by using the ATLImage library.

CImage Image;
Image.Load (L"D:ImagesPNG_ImagesImage7.png");

how to retrieve the byte array value of this png image. I tried retrieving it as

byte *png = reinterpret_cast<BYTE *>(Image.GetBits());

but when i access the data , der is a loss of data while converting it in the above manner.

I found a snippet in net for decoding the raw data . but der is a line is the code which is unknown to me. The code is as follows :

CImage atlImage;
HMODULE hMod = GetModuleHandle(NULL);
atlImage.Load(bstr);
void* pPixel = atlImage.GetBits();
intpitch = atlImage.GetPitch();
intdepth = atlImage.GetBPP();

[Code] ....

How do I get the byte * value form the png image loaded?

View 3 Replies View Related

Visual C++ :: Draw Image Using 2D Byte Array?

Feb 8, 2013

I like to Draw an Image Using two dimensional byte array[512][256].

I used SetPixelV method to plot the image.

But Its very slow & hidden some buttons(Controls) at run time in the same dialog.

For reference i send some code,

Code:
for(row = 0; row <512; row ++)
{
for(col = 0; col < 256; col++)
{
Data[row][col] = y;
SetPixelV(d, 10+row, 10+col, RGB(Data[row][col],Data[row][col],Data[row][col]));
}
}

View 14 Replies View Related

C++ :: Saving RGB Pixel Data Of JPEG Image In 3D Array

Jan 6, 2015

I need to save RGB values of each pixel in a 3D array A[width][height][3]. I found a code online that transfers the bytes into an array but I cant understand how bytes are saved them so i could transfer them into an array. The truth is I dont know much about working with images at all so i have a problem working on them. How to transfer the RGB data from an .jpeg image into a 3D array? This is my code so far:

#include <iostream>
#include <jerror.h>
#include <jpeglib.h>
using namespace std;
int main(){
FILE *pic = fopen( "image.jpeg", "rb+" );

[Code] .....

View 6 Replies View Related

C/C++ :: Read BMP Image Data Into Multidimensional Array Of Structures

Apr 8, 2014

I am trying to read the information from a .bmp file into my program while dynamically allocating memory for all of it. So I defined the structures for the headers and for a pixel, and then I have to read each pixel into a multi-dimensional array of pixels. I am completely new to structures, and definitely new to pointers combined with structures. I will have to use a filter with the information later, but right now I just want to read everything in correctly. The array of pixels will be two-dimensional -- the width by the height of the image, I guess.

Here's my code:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *inFile, *outFile;
typedef struct

[Code] ....

View 4 Replies View Related

Visual C++ :: Using 2D Array - Displaying Bitmap Image With Scrolling

Mar 11, 2014

My requirement is,

Read *.bmp image and displaying bitmap image with scrollbar in a MFC dialog application.

I was done using this

I was read the *.bmp image as a pixel data and stored by 2D Array,

Now i want to Display this 2D array as bitmap image with scrollbar separately in the same dialog. How can i display bitmap with scrollbar using 2D array?

View 10 Replies View Related

C++ :: Class Which Loads Bitmap Image Into One Dimension Char Array

Aug 27, 2013

I am writing a class which loads a bitmap image into a one dimension char* array.

This class has methods to allow for resampling and cropping the image before saving the bitmap image. It works perfectly for all images in which the width is divisible by 4. However when the width is not divisible by 4 the resulting bitmap is all mixed up.

I have spent much of the day googling this problem but to no avail. I know it is a problem with making sure the scanlines are DWORD aligned, and I believe I have done that correctly. I suspect that the problem is that I need to take the padding into account during the crop for loops but am lost to how to do this.

BTW: Coding on Linux using GCC

The following code is a cut down version from my bitmap class. I have removed methods which are not needed to make reading a little easier.

#include "BMP.h"
// FIXME (nikki#1#): Portrait bug on images of specific sizes
// TODO (nikki#1#): Memory leak checks
// THIS METHOD WRITES A BITMAP FILE FROM THE CHAR ARRAY .
bool BMP::saveBMP(string fileName, string *err) {
FILE *filePtr;

[Code]...

View 2 Replies View Related

C++ :: Create Array Of Playing Cards / Assign Values And Suits Then Shuffle The Array

Nov 24, 2014

I got this program to create an array of playing cards and assign the values and suits and shuffle the array. I'm at the point where I need to output the cards but I need to burn the first card by making it output "**" instead of the card. my cards[] is a constant so I can's assign the first card as such.

void showCards(const int cards[], int numCards, bool hideFirstCard) {
if (cards[0]) {
hideFirstCard=true;
cards[0] = '**';
} for(int a = 0; a <= numCards; a++) {
cout >> showCard(cards[a]);
} }

View 1 Replies View Related

C :: Create A Box Outside Array?

Dec 1, 2013

I am trying to create a box outside my 9x9 array. However, my box did not cover up everything.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>

#define row 19
#define col 19

[Code] ....

View 6 Replies View Related

C++ :: How To Create Array Of Nodes

Feb 10, 2015

I am trying to see if I can create an array of nodes. I think I have it down somewhat but this is what I have.

Code:

#include <iostream>
using namespace std;
/*This is a template of a person....sorta*/
class person{
public:
int data[32];
bool selected = false;
person(){

[Code]...

I am trying to see if there is a way for me to create a 86 slot array of person nodes. I am not sure how to do it and how to access them afterwards. I know that I am creating the bitstring of person correctly but I am not sure how to get the array of person going.

View 7 Replies View Related

C :: How To Create 8 Dimensional Array

Dec 19, 2014

Is it possible to create an 8 dimensional array in C? If no, then what can I do to improvise or let say bypass the limit?

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved