Your SlideShare is downloading. ×
  • Like
Learning by sample    gdi+ - lines
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Learning by sample gdi+ - lines


For more tutorial visit

For more tutorial visit

Published in Education
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. GDI+ : Lines 2010Learning By Sample Series GDI+ : Lines www.BukanSembarang.Info©2010 Page 0 www.BukanSembarang.Info©2010
  • 2. GDI+ : Lines 2010 Foreword Learning By Sample ? So, why should I made this tutorial freely accessed by everyone ? Well, surely I am just nobody, I also just another ordinary person with ordinary knowledge. However, I always feel that some persons in the internet giving away their tutorial for free and I feel being helped by them. Then, I remember one of my senior wisdom words : “If you want to be given more, then start to give more”. And of course, I really believe those words, since that I already proof it to be right all the time. Also, I’m not an English native speaker, however, I just try to improve my English in any other way, especially in written format. Thus, I think writing is the best practice to improve my English freely. However, you will find many grammatical errors in my tutorial, so please send me comments and also suggestion to improve it. Then, why the format using Learning By Sample series ? Is it really different with other tutorials out there ? Ehm, I already wrote three books (in Indonesian) using this kind of format, and many readers already contact me about how this format really help them to learn from the scratch. So, why in the world I’m not re-create it in English format, right ? Eventhough actually, it is similar with Hands On Lab series which already famous in Microsoft site previously. All of my lesson also being designed as short samples and short time exercise. Thus, I hope that each of tutorial series would take only at least 10-15 minutes maximum to learn. Why keep it short ? Because many beginner (and even expert) will find boring whenever they must keep studying more than 15 minutes (but you will never get bored when you online in such time right ?). www.BukanSembarang.Info©2010 Page 1
  • 3. GDI+ : Lines 2010 Another reason is just because many of samples in this series come up from my lecturing task exercise. So, I just try to compile all my lab exercises in order to keep it tidy and also reusable for my students. That’s why you will find many unsorted course material inside these series, however, just take a seat and enjoy the ride ! Requirements In this series, I try to give simple example about GDI+. So what is GDI+ anyway ? GDI+ or GraphicsDrawing Interface is merely part of .NET Framework which entirely purposed in manipulating graphics. However I’m not going to make you understand complex theory about this class. I just try to make you understand it in very simple and stupid way. All of my samples in this series use Visual Web Developer 2010 Express edition however you can also do it all using Visual Studio. If you really want to follow this series, then you should aware that basic programming knowledge is needed. You should also familiar with ASP .NET especially for version 3.5 above. FYI, I’m a VB guy, so please don’t complaint if I use VB entirely in this series. But nowadays, there’s no such useful things if we argue about language differences, because I just try to share something that I know. So, if you don’t like VB and want to have another tutorial with your own favourit language, then I’d be happy to read it. Now, let’s get started……. www.BukanSembarang.Info©2010 Page 2
  • 4. GDI+ : Lines 2010 Let’s Get Started 1. First, ensure that you already open Visual Web Developer 2010 Express Edition 2. Create a newly blank website and give it a name 3. Now, let’s create a new blank web page www.BukanSembarang.Info©2010 Page 3
  • 5. GDI+ : Lines 2010 4. Next, put a text for labelling with a Textbox and a Button. Also add an Image control right below. Thus, the web page should be look like this picture : www.BukanSembarang.Info©2010 Page 4
  • 6. GDI+ : Lines 2010 5. Very simple right ? Then let’s go on to next step. Just double click at the Button to go to Code Editor, and type this code : 6. Some errors showing ? Don’t worry, just type this reference command at the top of your code : 7. So, what is really happen in those lines of code ? Here is the explanation : a. First, we must import reference of System.Drawing at top of all code to use GDI+ www.BukanSembarang.Info©2010 Page 5
  • 7. GDI+ : Lines 2010 b. Then we must declare a Bitmap with certain dimension (in this sample I use 300x 300, but you can modify it of course). Just assume that this Bitmap is like your canvas which will be ready to be painted later. c. Now take a look at Graphics variable which took place from Bitmap object. This Graphics object then being cleared using White background color. d. Then using simple looping, we just create Line object in Black color. e. Afterward, just save the result into a temporary image file named as test.png. This technique absolutely not an efficient one, however, this is just www.BukanSembarang.Info©2010 Page 6
  • 8. GDI+ : Lines 2010 the beginning and I will show you later the other technique in other tutorial chapter. f. So, we already got the result, then just display it into Image control. g. Also don’t forget to dispose all the previos declared object, thus we can execute this web page over and over again. 8. Now, let’s execute this simple web page, just press Ctrl+F5 and see what happen : www.BukanSembarang.Info©2010 Page 7
  • 9. GDI+ : Lines 2010 9. Don’t you think it’s very quick and easy ? Well, it’s late midnight and my filter kretek is running out, see you in following tutorial then….. www.BukanSembarang.Info©2010 Page 8