Wednesday, February 15, 2012

Fastest method for pixel plot in windows form application using c sharp sample example

In my previous articles I have shown you how to draw a pixel in picture Box. In that method we have drawn pixel directly in control of picture Box so it was slow method. Here I am presenting the fastest method to draw a pixel. For this technique we first draw a pixel or bitmap in memory then only we load it in out picture Box.
Now lets start a project
1. Create a windows form application in c sharp and give project name fastPixelPlot or your choice.
2. Set the the form properties WindowState to maximized from properties window
3.Add pictureBox on a form from toolbox
4.Set pictureBox properties Dock to fill from properties window
I assume your form name is Form1 and pictureBox name is pictureBox1

Download complete application from GitHub.

Sunday, February 12, 2012

Delay function in codeblocks

In code block you can use
Sleep(unsigned int miliseconds);
function for delay in execution.
delay(unsigned int miliseconds) function is used in turbo c. For codeblocks you have to add code which is given below example:
void delay(unsigned int mseconds)
    clock_t goal = mseconds + clock();
    while (goal > clock());
int main()
    int i;
    printf("This is delay function\n");
    return 0;

Saturday, February 11, 2012

Drawing a basic shape in windows form application using C#

There consists of the set of .NET base classes that are available to control custom drawing on the screen.Here we learn how to draw basic shapes in windows form using C#. This articles is simple collection which I read while doing graphics projects.
Before starting create a new project in windows form application using C# and I assume that your name of form is Form1. Increase the size of form up to 720*600 in properties windows.Now we draw a shapes by creating graphics object and pen or brush object and these class are from namespace system.Drawing.
At first we have to initialize the paint event handler by adding
this.Paint += new System.Windows.Forms.PaintEventHandler(this.MainForm_Paint); 

line of code in Form1.Designer.cs inside private void InitializeComponent() method. If you don’t do this  then your image won’t draw in form although compiler doesn’t shows any error.

Tuesday, February 7, 2012

Drawing pixel directly in windows form using c# and implementing DDA Algorithm to Draw a straight line.

In windows form application pixel operation method is different then C++ builder.There may be many techniques to Draw single pixel and one of them I have presented here.Usually in windows form, code is generated by IDE using drags and drops controls which is specifies by the System.Drawing namespace.We can also draw basic shapes and curve by creating graphics objects and pen objects to paint a various shapes. We will create graphics object but not pen object because we won’t draw a basics shapes only draw pixels.

Friday, February 3, 2012

Draw a 3D Rubik cube using OpenGL utility toolkits GLUT with source code

This article is similar  to my previous article drawing 3D chess board.To make Rubik cube real I have used texture mapping.At first I draw a one cube where I mapped texture in all six side of cube with six different color images and you can save these images from here.After that 27 cube is drawn by looping and final Rubik cube is drawn, rotating in (2,2,0) axis.For texture mapping we have to write a code to load a images and store a value of (R1,G1,B1,R2,G2,B2,……………)pixels in pixels array.In this project there is a Image class where you can see in source code below in file name imageloader.h and imageloader.cpp which I have take from a website
All the images for this program is given below save it in your project file location.