Tags » Computer Graphics

Instant Radiosity in my Renderer

I read about this instant radiosity algorithm in the book physically based rendering 3rd these days. It is mentioned as instant global illumination though, they are actually the same thing. 1,550 more words

Computer Graphics

The Missing Primary Ray PDF in Path Tracing

I was always wondering why don’t we take the PDF of primary ray into account in a path tracer. Sadly there aren’t many resources available explaining it. 1,159 more words

Computer Graphics

Compiling and Linking GIMP Toolkit ( GTK+) with C / C++ project

What is GTK+?

GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off tools to complete application suites. 39 more words

Computer Engineering

DDA Line Algorithm using GIMP Toolkit ( GTK+)

/* GTK Code for DDA Line Algorithm */

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

/****** For Window Size of 512 X 512 ********/
#define IMAGE_WIDTH 512
#define IMAGE_HEIGHT    512

/**** Global variables for defining RGB color; Default WHITE= (R=255, G= 255, B= 255)******/
int R=255, G=255, B=255;

guchar rgbbuf;

gboolean on_darea_expose (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
  gdk_draw_rgb_image (widget->window, widget->style->fg_gc,
          0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
          GDK_RGB_DITHER_MAX, rgbbuf, IMAGE_WIDTH * 3);
  return TRUE;
}

int putpixel(int x, int y){
if ( x < 0 || x >= IMAGE_WIDTH || y < 0 || y >= IMAGE_HEIGHT )
return -1;

int pixel_buf_loc =  IMAGE_WIDTH * 3 * y + 3 * x;
rgbbuf[ pixel_buf_loc + 0] = R;
rgbbuf[ pixel_buf_loc + 1] = G;
rgbbuf[ pixel_buf_loc + 2] = B;
return 0;
}

/****** function for defining RGB color combination ********/
int setcolor(int r, int g, int b)
{
R=r;
G=g;
B=b;
}


/****** function for DDA line Algorithm ********/
int ddal(int x1,int y1,int x2,int y2)
{
int n,sin1,sin2,steps,i,c1;
float dx=0, dy=0, xincr, yincr;
float x=x1,y=y1 ;

dx = x2 - x1;
dy = y2 - y1;

if(abs(dx) > abs(dy))
steps = abs(dx);
else
steps = abs(dy);

xincr = dx / (float)steps;
yincr = dy / (float)steps;

i = 1;


setcolor(255,0,0);   //RED

do
{
x = x + xincr;
y = y + yincr;
i++;
putpixel(x+ 0.5,y+ 0.5);
}while(i <= steps);
printf("The last value of the point plotted is: (%d, %d)", x1, y1);
}

/******main function********/
int main (int argc, char *argv[])
{
int x1, y1, x2, y2;


GtkWidget *window, *darea;
/*    */

gtk_init (&argc, &argv);

 /* Create the main, top level window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);


darea = gtk_drawing_area_new ();
gtk_widget_set_size_request (darea, IMAGE_WIDTH, IMAGE_HEIGHT);

/* Plot the label onto the main window */
gtk_container_add (GTK_CONTAINER (window), darea);
gtk_signal_connect (GTK_OBJECT (darea), "expose-event",
GTK_SIGNAL_FUNC (on_darea_expose), NULL);

 /* Make sure that everything, window and label, are visible */
gtk_widget_show_all (window);

//Set background white
memset(rgbbuf, 255, IMAGE_WIDTH * IMAGE_HEIGHT * 3);

printf("\n enter x1 = ");
scanf("%d",&x1);
x1 = x1 + IMAGE_WIDTH / 2;

printf("\n enter y1 = ");
scanf("%d",&y1);
y1 = IMAGE_HEIGHT / 2 - y1;

printf("\n enter x2 = ");
scanf("%d",&x2);
x2 =  IMAGE_WIDTH / 2 + x2;

printf("\n enter y2 = ");
scanf("%d",&y2);
y2 = IMAGE_HEIGHT / 2  - y2;
ddal(0,IMAGE_HEIGHT / 2,IMAGE_WIDTH ,IMAGE_HEIGHT / 2);
ddal(IMAGE_WIDTH / 2, 0 ,IMAGE_WIDTH / 2,IMAGE_HEIGHT );
ddal(x1,y1,x2,y2);


/*
    ** Start the main loop, and do nothing (block) until
    ** the application is closed
*/

gtk_main ();
return 0;
}


… 23 more words
Computer Engineering

Ai to Photoshop

In week 7’s CG class, we learnt about the use of Vector art into Bitmap Editing. A process of where you drag a vector from Adobe Illustrator to Adobe Photoshop. 205 more words

Computer Graphics

Assignment 2

For the second CG assignment, we had to do a photo book. Some themes were given, first I thought of doing a photo book for Hari Raya Aidilfitri/Aidiladha, but then I saw some of my cousins wedding photos that I took last year, so… I changed my mind and did a wedding photo book. 474 more words

Computer Graphics

Simple Text Manipulation

In CG class, week 6, we learnt how to do a simple text manipulation. The lecturer gave some videos for us to watch and gave us work, which is obviously to create manipulated text. 178 more words

Computer Graphics