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
ADVERTISEMENT
Oct 6, 2012
i wish to plot a mathematical function on a 2-dimensional grid. The function will be represented by 3 sets of floats, x-values, y-values, and z-values. Obviously, it is impossible to plot 3 such data sets on a 2D grid, so one approach is to use pixel coloration to represent the z-values.
Those examples (and there are many to be found) show something like the function of the complex variable z, f(z) = exp(z). I have attached a exp(z).jpg example of the imaginary part of the plot exp(z).
My question is: How to accomplish such a gradient colorization, assuming one already has the data?
I have experimented with Gdiplus SetPixel, but I have not figured out how to produce a smooth gradient.
Here's my attempt to create a simple gradient:
Code:
CDC * pDC = GetDC();
Graphics graphics(pDC->m_hDC);
CRect r;
GetWindowRect(&r);
ScreenToClient(&r);
[Code] ....
View 1 Replies
View Related
Jan 13, 2014
Is there any way that I can call a function/receive an event whenever an external window (not any of my forms) repaints/draws?
If you create a GDI+ graphics object and give it the HWND of another window that refreshes a lot like a web browser, anything with animated graphics, your draws and the windows draws are out of sync which creates an intense flicker effect.
Googling this issue only brings up results for handling when my own form repaints...
My idea is that I could just redraw my GDI stuff whenever the form redraws, this is indeed possible?
View 9 Replies
View Related
May 8, 2014
How can I draw a sprite/graphic on the window of an third party application? E.g. I want to draw a graphic beneath each tab of Firefox for additional information. The position of the sprite needs to be relativ to the position of firefox, so if you move firefox, the sprite moves with it.
The solution needs to work on mac and pc. So I'll use a crossplatform framework like c++ boost or something.
Of course I can get the position and then just redraw it. But what's the best way to draw it?
Just found a tool which does what I need. Basically a HUD like this: [URL] .... The boxes with the numbers are what I need.
View 2 Replies
View Related
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
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
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
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 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
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
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
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
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
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
Jul 21, 2013
I'm currently working with linear VRAM (a buffer with 256KB memory, divided into four 64k planes, so plane 0 at 0x00000, plane 1 at 0x10000, plane 2 at 0x20000, plane 3 at 0x30000). Just add the index of the plane to that for the full address in VRAM.
I'm still wondering how to get a specific pixel from VRAM (x,y coordinate) when doing graphic modes (none color modes work, only the black/white pixels (1-bit) graphic mode works).
how I can get specific pixels from the VGA VRAM (having linear access described above) using Shift Register Interleave mode (VGA modes 4&5), 16-bit planar mode (Most VGA modes) etc.
View 4 Replies
View Related
Apr 7, 2013
I have tried everything and i still can't access pixel RGB values in float format.
I tried vec3b which produces strange characters which i can't covert to float as it says no suitable function exists.
I tried vector<float> RGB;
with RGB = image.at<vector<float>>(row,col);
I get a unhandled exception error.
So whatever i do, if it is syntax correct i get unhandled exception error. If it should work i get this stupid error. I need it for chroma keying.
View 4 Replies
View Related
Jan 27, 2015
I have a bw(grayscale) image and want to calculate the slope for each pixel which returns a value 0 to 255 value.
Pixels are always between 0 and 255. The highest possible difference is 255. The end result would be 0 for no slope and 256 for the highest slope.
Would this formula work?
slopex = pixel[x+1,y] - pixel[x - 1,y];
slopey = pixel[x,y+1] - pixel[x,y - 1];
totalslope = sqrt(slopex * slopex + slopey * slopey)*256;
View 3 Replies
View Related
Jan 18, 2015
I have managed to successfully extracted the BMP file header and file info but ran into troubles with getting the pixel data out into a 2d array.This is my function to read the data while i have another to write the data. The output does not match the input at all.
void BMPProgram::GetPixelData(std::ifstream & inStream) {
std::cout << "Entered function";
if(inStream.fail())
return;
//space allocated to reading in of padding
int paddingSpace = 0;
[Code] ....
PIXEL is a struct of 3 unsigned char containing values of RGB.
View 3 Replies
View Related
Feb 28, 2014
I'm trying to read a jpeg pixel and then compare it if it'x bigger than a number to change it. Either I'm breaking the folder if I start less than 22000 which is very large number shouldn't include the header or I'm getting solid color without any different.
Code:
const char* filename ="Hydrangeas.JPG";
const char* nfilename ="Hydrangeas1.JPG";
FILE *ptr_old, *ptr_new;
errno_t err = 0, err1 = 0;
int a;
[Code] ....
View 5 Replies
View Related
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
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
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
Mar 13, 2014
I'm trying to blur a ppm image by averaging the components of the color(r, g, b) within a certain reach of a specific pixel. This is a picture and description:
In this diagram, we are trying to compute the color for the pixel in the center (the red element). Its neighbors (within a reach of 4) are all of the green elements. The pixels outside of this 9x9 square are not considered in the blurring calculation for this pixel. To compute the color for the center pixel, average the red, green, and blue components (independently) of every pixel in the 9x9 square (including the pixel itself; the red element in this diagram).
I have some code, but it is not working correctly. The function "computed_color" on line 52 is shown in the next block of code.
Code:
#include <stdlib.h>
#include <stdio.h>
#include "blur_calculations.h"
#define NOT_ENOUGH_ARGS 2
#define MIN_ARGS 3
#define PICTURE_FILE 1
#define REACH_NUMBER 4
#define OUTPUT_FILE "blurred.ppm"
#define PPM_NUMBER "P3"
#define MAX_ROWS 500
#define MAX_COLS 500
void solve(FILE *in_picture, FILE *out_picture, char *argv[]) {
[Code] ....
Here is my code to calculate the average, which I use in my "solve" function:
Code:
#include "blur_calculations.h"
struct color create_color(int r, int g, int b) {
struct color colors;
colors.r = r;
colors.g = g;
colors.b = b;
return colors;
[Code] ....
View 4 Replies
View Related
Nov 16, 2013
I am fairly new to c++, and I want to be able to draw a polygon. When I have searched for how to draw one, the only thing i can find is scripts doing things like this:
*
**
***
****
*****
I doubt that c++ is that primitive, and I'm looking for something like the c++ equivalent of this python script:
Syntax: draw.polygon((20,20)(30,30)(50,30)(20,40)(20,20), fill(green))
I am using a mac os 10.9
View 2 Replies
View Related
Aug 20, 2013
I'm trying to create a grid using the following characters: !, @, #, $, &.
It's an 8 x 8 grid, and should contain the characters in no particular order (trying to create a Bejeweled-like game).
I already defined the width and length to be 8, so:
#define WIDTH 8
#define LENGTH 8
Code:
void makegrid(char grid[])
{
int j;
int k;
for ( j = -1; j < LENGTH; j++ )
{
for ( k = -1; k < WIDTH; k++ )
{
/* I don't know what to type here anymore :( */
}
} }
View 14 Replies
View Related
Jun 22, 2014
This is my first time using opengl and I am experimenting with adding/drawing polygons/points/etc. on top of a PPM image. The image is already loaded when the application runs. My attempt to draw a square is from lines 30 - 35. The program runs but the square is not present. Just the image.
#include<windows.h>
#include <stdio.h>
#include <stdlib.h>
#include<Gl/gl.h>
#include<GL/glut.h>
int n;
int m;
int *image;
[Code] ....
View 5 Replies
View Related