C :: Functions To Work With Graphics Card - Read Pixel Map

Nov 25, 2014

In this project I need to develop few functions to work with graphics card. I work in minix and this is pretty rubbish.

I'm having an hard time to read a pixel map, or atleast to print it on my main function.

I have a read_xpm function, which is given, therefore, working.

Code:
char *read_xpm(char *map[], int *wd, int *ht)

Then I have a pixmap.h file which gives some examples of pixmap images that I can use as example:

Code:
static char *pic1[] = {
"32 13 4",
". 0",
"x 2",
"o 14",
"+ 4",

[Code] ....

The doubt is. I have a test_xpm function and I need to call this char array but this is so many pointers that I can't even figure out where I'm pointed to (?)

Code: int test_xpm(unsigned short xi, unsigned short yi, char *xpm[])

I tried something like read_xpm(xi, yi, *xpm[0]); but I'm guessing I need to index that array and run all those chars in order to show them.

View 11 Replies


ADVERTISEMENT

C++ :: Using Clear Device And Sleep Functions In Graphics

Dec 14, 2014

I have a college project which is a car racing game using C++ and the old-school graphics library BGI. After I draw the map and placed the objects(Car,obstacles,road's borders etc..)I added Sleep(); function to the function named Obstacles(); but the problem is, I can't move the car with the right&left arrows.a

Another problem,If I added a cleardevice(); command all objects disappears only the obstacles function keeps working. the Code is here:

char c;
do{
c = (char)getch();
if (c == KEY_LEFT) {
x = x - 10, x1 = x1 - 10;
} if (c == KEY_RIGHT) {
x = x + 10, x1 = x1 + 10;

[code].....

note: this is not the whole code, it's only a small portion of it, not a debugging question only need a hint how to fix it.

View 3 Replies View Related

C :: Read Text File From Memory Card Using Threading

Mar 25, 2013

I need do read a text file from memory card using threading.

I am able to do it with out using thread but because of some limitations, i have to do it with threading only.

Here is the code to read file from memory card with out thread:

Code: ##########################################
#include <stdio.h>
#include <stdlib.h>
#include <XMC4500.h> /* SFR declarations of the selected device */
#include <DAVE3.h> /* Declarations from DAVE3 Code
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

[Code]...

View 4 Replies View Related

C/C++ :: Name And Lastname Search Functions Won't Work?

Jan 1, 2015

I made a function as my project and name search/lastname search functions are not working and giving a runtime error. I can't really see the mistake. So what's wrong it?

Also ID and Mark search system has some bugs with them, whenever you search for an ID it also brings mark = 0, also if you search for Mark, it will bring ID = 0.

Exact error is; Unhandled exception at 0x6583f5cf in proje10.exe: 0xC0000005: Access violation writing location 0x00eb0000.

Full code:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

[Code]....

View 1 Replies View Related

C++ :: Make A Function Integrate To Work With Other Functions Given

Mar 10, 2013

We have to make a function integrate to work with the other functions given. I had it working before but I would only get all -4 as my answers but only the first one should be -4. what should more or less be put in my integrate function?

#include <iostream>
using namespace std;
typedef double (*FUNC)(double, double, double) = (line, square, cube);
double integrate(double FUNC, double a, double b){
for(int i=0; i<a && i<b; i++){
FUNC = a-b;

[code]......

View 2 Replies View Related

C++ :: Read And Write Multiple Class Objects From File - Fstream Won't Work Correctly

Apr 28, 2014

So I have a small program which is supposed to write and read multiple objects from a file, but for some reason it doesn't write the information when I use "fstream" to create the object from the fstream class, but it does when I use "ofstream". Also, it doesn't read the information from the file no matter if I use "fstream" or "ifstream". I watched a video where this exact code worked just fine, but it just won't work when I run it. I'm using Dev C++ 4.9.9.2, I don't know if that has anything to do with it, I also tried it with Code::Blocks, didn't work either.

Here's the code.

#include <iostream>
#include <fstream>
using namespace std;
class Person

[Code].....

View 3 Replies View Related

C++ :: White Pixel Value Different From 255

Mar 12, 2014

I am working on image processing in C + + and opencv, I treat images in grayscale, ie the pixel values ​​it must be between 0 (black) to 255 (white).

Mat img; img = imread (file, -1);
for ( int i = 0; i < img. rows ; i ++) {
for ( int j = 0; j < img. cols ; j ++) {
val_pixel=img.at < double >(i,j);
printf( "%d ",val_pixel);
}
printf( "
");
}

when displaying the pixel value from two loop, I get values ​​to 0 and it is normal for propablement black areas, but for whites I find the value -2147483648. I don't understand why this value is not 255.Is there an explanation for this has value.

View 4 Replies View Related

C++ :: SDL2 - Getting Pixel Value

Nov 5, 2013

I use SDL2. and i was testing some functions i took from some internet and some unwanted results happened.

Code :

Pixel *GetPixel(SDL_Surface *surface, int x, int y) {
Uint8 p8, *buf8;
Uint16 p16, *buf16;
Uint32 p32, *buf32;
switch(surface->format->BitsPerPixel {

[Code] .....

And the output changes time to time.

View 3 Replies View Related

C/C++ :: Get Dimension Of Pixel In Mm?

Apr 17, 2012

I have an image of size 640x480 pixels. It's possible to obtain the dimension in mm of one pixel from that image given only that size?I do not have the size of the image in mm,however.

View 5 Replies View Related

C++ :: How To Find Each Pixel In The Circle

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

C :: How To Initialize Deck Of Card

Mar 25, 2014

The deck of cards so it is populated with all 52 cards. Once you have populated the deck, you need to shuffle the deck. Here is a simple algorithm you might consider for this purpose:

For each card up to the middle of the deck generate a random number modulus the size of the deck, swap the current card with the card at that location done

To implement this requirement you need to implement and use the following functions:

void initDeck(Card * deck);

View 4 Replies View Related

C++ :: Getting Pixel Information From Fonts?

Mar 27, 2013

How can I import a font file and get the pixel information of the letters so I can make my own custom text drawing function?

I basically have a pixel surface (a 2D array) and I want to draw the text to that array.

View 1 Replies View Related

C++ :: Rotating Pixel Field

Apr 21, 2014

I wrote a script that generates n random pixel positions and draws them to the screen. Works well. Now i tried to rotate them. Rotating does work too. But it does not work as i planned it.

paramters 'angle' and 'timestep' work somehow, but not as they should do. the function 'move' is supposed to rotate the pixelfield 'angle' degrees in a given direction, addicted to the 'timestep' parameter. 'timestep' is needed time for drawing in one single game loop.

angle_step = timestep * angle
// x
ppdPoint[i]->x =
pRotationPoint->x + cos(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) - sin(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);
// y
ppdPoint[i]->y =
pRotationPoint->y + sin(angel_step) * (ppdPoint[i]->x - pRotationPoint->x) + cos(angel_step) * (ppdPoint[i]->y - pRotationPoint->y);

rotation point is the middle of the screen. when i set angle to 10 it should rotate 10 degrees / second. Instead it's rotating very very fast and all stars are moving nearer to the center of the screen, so after x rounds there is just 1 pixel left in the middle of the screen. there is a kind of gravition.I'm working with SDL2. What I did find out:

FPS is <= 60, 'cause of the 'SDL_RENDERER_PRESENTVSYNC' flag. When i skip that flag, for any reason the 'gravition' would take more time. FPS is <= 1400 then, 'though i got a natural game loop (i hope):

while(pBuild->getExecuteFlag())
{
pBuild->draw();
pBuild->update(time_dif, pTimeWindow->TimeStampB);
time_dif = (pTimeWindow->TimeStampB - pTimeWindow->TimeStampA);
time_dif *= 0.001;
pTimeWindow->TimeStampA = pTimeWindow->TimeStampB;
pTimeWindow->TimeStampB = SDL_GetTicks();

pBuild->count_fps(pTimeWindow->TimeStampB);
}

So maybe (timestep * angle) isn't the right way?

View 13 Replies View Related

C++ :: Display Of Card 2D Array

Sep 9, 2013

i was reading trying to get it how to display the out put, all i got to is how to declare the arrays. How to start it also i saw some examples have " struct card"

the display should look like this:

2c 2h 2s 2d
3c 3h 3s 3d
4c 4h 4s 4d
5c 5h 5s 5d
6c 6h 6s 6d
7c 7h 7s 7d
8c 8h 8s 8d
9c 9h 9s 9d
10c 10h 10s 10d
Jc Jh Js Jd
Qc Qh Qs Qd
Kc Kh Ks Kd
Ac Ah As Ad

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int deck [13][4];
string suits [4] = {"h", "d","c","s"};
string values [13] = { "2", "3", "4", "5","6", "7"," 8" ,"9", "10"," J", "Q"," K" , "A"};
system ("pause");
return (0);
}

View 2 Replies View Related

C# :: Cricket Score Card?

Mar 24, 2010

I have to develop an application named smart client score board in c#

Main requirements for this application are that application should display the live scores, detailed score board, running commentary (in text), players and team profiles, statistics of matches, results and fixtures for cricket.

sort out websites which support rss feeds for full score card.

View 6 Replies View Related

C# :: Draw Single Pixel On Window

Mar 27, 2014

Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like a radar PPI screen. Trying to do this in c#, I can't find how to draw a single pixel on the window.

Also, what should I be drawing on: the form, panel, picturebox...?

View 2 Replies View Related

C++ :: How To Convert Pixel To Coordinate In OpenGL

May 23, 2013

How can i convert pixel to [-1..1]coordinate in opengl? Which function? I want to write a program that is work with

glutmousefunc(),

When I click on the screen a ball is appear on it where clicked. but mouse work with pixel and circle work with coordinate between -1 and 1 ....

View 4 Replies View Related

C++ :: Subtracting Pixel Values From Two Different BMP Files

Dec 30, 2014

I would like to subtract one image from another to get something like "differential picture" (i am not sure whether the name is correct). I've managed to read the FILEHEADER and FILEINFOHEADER of bitmap. I will subtract 24-bit bmp files only. However i can't understand the structure of this file. So far my code looks like this. Any example of at least copying one bmp file to a new one? This example would be useful, because subtracting will be simillar, instead of copying the pixel value i will just put abs(value1-value2) in the output.

Code:

// ConsoleApplication1.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
struct BITMAPfileHEADER {

[Code] .....

View 4 Replies View Related

C++ :: SFML 2.0 Pixel Perfect Collision

Oct 15, 2013

I have the code and it compiles fine but it doesn't work. (i am using the coding made easy sfml 2.0 tutorials)

Code:

#include <SFML/Graphics.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
class Player {
public:
sf::Sprite player;

[Code] ....

View 18 Replies View Related

C++ :: SDL Library - Access To Pixel Data

Mar 7, 2013

I am using the SDL library, and came across a way to access pixel data.

//A pointer to a surface structure

SDL_Surface *w = SDL_SetVideoMode(800,400,8,SDL_SWSURFACE);

//Casting a void pointer pointing to an array of memory locations(the pixels), to a pointer to an array of Uint8's.
//SDL_MapRGB() Returns an Uint32 containing the color 0,0,255,(0/255, i think it returns the transparency too, or else it would rather return a Uint24,not sure).

Then modifying the memory location, in this case the pixel at the middle of the window.

static_cast<Uint8*>(w->pixels)[(200*w->pitch)+400]=SDL_MapRGB(w->format,0,0,255);

What i seem to not understand is that, i cast pixels to Uint8*, which means I now have a pointer to an array of 8bit numbers, but SDL_MapRGB seemingly returns an Uint32 or Uint24 for a color composed of r,g,b, together without 'a' is 24bits(256=1b,256=1b,256=1b)=3b.

And then i somehow assign that pixel which is of 8bit at chosen location, an Uint24 or 32bit unsigned int.

How does this work?

View 3 Replies View Related

C++ :: Program To Generate A Report Card?

Aug 28, 2013

For a school homework i had to make a c++ program to generate a report card so i made this program

#include<iostream.h>
#include<conio.h>
void main()
{

[Code].....

The problem is that it does not take any values ps I have been learning C++ for 3 months so we don't have any arrays,at max we have iterations

View 5 Replies View Related

C++ :: 3D Graphics With Quaternion Data

Jul 7, 2014

So I've got a sensor (contains a gyroscope, accelerometer, and magnetometer) that outputs quaternion data. I'm looking to take that data and use it to display the rotation of my sensor in the form of some object on the screen. I've seen instances where programs use a cube, but I'm hoping to figure out a way to have a little more control over what the object I'm rendering is.

how to get started? Are there any software packages that might be able to accomplish this?

View 1 Replies View Related

C++ ::  SFML - How To Put Graphics Into Program

Oct 18, 2013

I use visual studio 2012. When I asked what I should use in order to put graphics into my program, I was told by the community that SFML works well. My only problem is that now I have SFML, where and how do I unpack it?

View 6 Replies View Related

C++ :: How To Make A Cursor Without Using Graphics

Nov 27, 2014

I'm new to c++ So I have a project to make. I need to make a cursor like an arrow that will move when inputs are given. e.g if input is given 500 spaces UP it will move up and so on. it should rotate as well like 45 degrees and so on. how to make this arrow WITHOUT USING GRAPHICS.

View 2 Replies View Related

C++ :: How To Write Graphics Pipeline

Nov 25, 2014

I have been learning Direct3D for a while now (DX11), and I ran into a bit of a dead end. I have Frank Luna's book on D3D programming, but I feel like I could find a better tutorial out there. I am at the point of writing the vertex shader (the first one he goes over)

Currently, I am using .fx files to write the shaders. Is that right?

View 10 Replies View Related

C++ :: Use 3D Graphics Obj Files Created With UDK?

Jan 6, 2013

How do I use 3D graphics .obj files created with UDK in a C++ project?

View 1 Replies View Related







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