Monthly Archives: September 2011

Pamphlets–Free Resources


Free Templates for making pamphlets and a sample as a reference. Download in Hi-Res from Here:

Background: http://fav.me/d4ba9n4

Foreground: http://fav.me/d4baa21

Slate: http://fav.me/d4baa7g

Tagged , , , , , ,

Combine two Images in C# by Overlaying [Open/Combine/Save]


Ok so here is the deal, Yesterday I came across a problem in which I had to overlay an image onto

basecardimg28Final

Template / Picture / Final Image

another and save it. For instance lets just say that you want to watermark images that a user uploads on a website and you have the source file and the watermark file. I searched for an image processing toolkit but  could not find many. So I dug the procedure by which Bitmaps are written in C#. and that did the trick.

First of all you have to load all your files in a string, you can either hardcode that or just call in a directory function and that will do the trick.

 1:  string[] files = Directory.GetFiles("PATH");

where PATH = C:\Documents and Settings \….. TO the folder where your images are.

Make sure there are only two files in the folder the source and target. Next up you have to load the image using a bitmap object. Don’t worry about the format, C# handles that automatically.

 1: Bitmap template = new Bitmap(files[0]);
2: Bitmap Picture = new Bitmap(files[1]);
Now that you have created the bitmap objects one final step remains, take one of the picture and map it on to other, I calculated the sizes of my pictures and set the margins so that it comes in center. You can always get the sizes using “.Width and .Height” properties.
for (int w=0; w<template.Width; w++){
                for (int H = 0; H < template.Height; H++ )
                { 
                    if(w>=60 && w<240){
                        if(H>=60 && H<390){
                            template.SetPixel(w,H,Picture.GetPixel(w-60,H-60));
                        }
                    }
                    template.SetPixel(w, H, template.GetPixel(w, H));

                }
            }
 and finally you can save this bitmap object in any format, the last property defines the target format.
 1: template.Save("PATH\Filename",System.Drawing.Imaging.ImageFormat.Png); 
Simple Eh?
Complete Code:
using System; 
using System.Collections.Generic; 
using System.Linq; using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.IO; using System.Drawing; 

namespace ExperimentWithImages {     
 public partial class _Default : System.Web.UI.Page     {         
 protected void Page_Load(object sender, EventArgs e)         {
              string[] files = Directory.GetFiles("PATH");  
            Bitmap Card = CombineAndSave(files);
              Card.Save("PATH/FileName",System.Drawing.Imaging.ImageFormat.Png);         }
 
          Bitmap CombineAndSave(string[] img) { 
            Bitmap template = new Bitmap(img[0]);
             Bitmap Picture = new Bitmap(img[1]);
             for (int w=0; w<template.Width; w++){  
               for (int H = 0; H < template.Height; H++ )
                 {                   
   if(w>=60 && w<240){
                         if(H>=60 && H<390){
                             template.SetPixel(w,H,Picture.GetPixel(w-60,H-60));
                         }
                     }
                     template.SetPixel(w, H, template.GetPixel(w, H));
                 }
             }
             return template;
                  }
     }
 } 

Tagged , , , , , , , , , ,

Send me Private Messages that nobody else can read


I know the heading sounds bizarre but really that is what PGP keys are meant forimage. By using PGP you can:

  • Send messages to me that nobody else can read.
  • Can verify if a document is genuinely signed by me
  • Can decrypt if I encrypt something and send it over online.

Cool isnt it?

You can search for the Key ID F10A245C in Hexa it is [0xF10A245C] on a public PGP key server. Alternatively you can also copy/paste the following into your PGP software:

—–BEGIN PGP PUBLIC KEY BLOCK—–
Version: GnuPG v2.0.17 (MingW32)

mQENBE5NVAoBCADlrsryI0tIYlvMHPQ/i5DAGGSvUEx50jGtl3i17aFBHeZYyzXG
VNUW9ZvCf/WQjrubt1rl+gEhCdlyOkn98EDpNwTHfFUZ4Zg8ILvq/Cm8iihk+E94
JAN4iCVz7NWyzJGkZ953n/JvdTljhLRAovwb9ycRVYX85zXi1q6PYErU1/tsEd8j
Zweu0LxotFvnWs1VhAT2xlX3BGaGTNpc9moZ23Wp0Wxy3yjlGQoJlQLH5LJypCCp
wfeXE+qTVQWMoiPew4ChClKUBWLSN9Ilbz9zeg8xXxJGjdWguTmZVBVUSnto+O2o
JLiDeqp7jxmuTy7feDJtpS7pSaTI14CV1uRJABEBAAG0LklmdGlraGFyIEFobWVk
IEJoYXR0aSA8d2hpenp5aWZ0aUBob3RtYWlsLmNvbT6JATgEEwECACIFAk5NVAoC
GwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJED2VcPbxCiRcdKEH/2B0pJ1t
4KH/huEkWJsiqO3jWhOCTZqBCsuD7LqIz5/LNYOSch78Ulz0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C KEY BLOCK—–

Tagged , , , , , , , , ,

A Fishing Tale


On Friday morning I along with my two cousins went out to have a go at fishing. I woke up at OLYMPUS DIGITAL CAMERA4:45 in the morning because we had planned to leave early. I had slept very little the previous night so I changed my clothes before sleeping. As the alarm buzzed off, I jumped out of my bed, gulped on a glass of juice and I was on the road.

Miraculously all three of us had woken up in time, so it didn’t take us more than 20 minutes to gather ourselves up. I along with my cousin Waleed provided breakfast support while our third cousin – Shehzad  – went out for  bait hunting, earthworms. In about 30 minutes or so we were set to leave. We had targeted three places for hunting:

  • Shahpur Dam
  • Rawal Lake Spillway
  • Rawal Lake Excess water tributary – more of a rainwater reservoir

So we started off for the farthest location first, Shahpur dam. Shahpur Dam is more of a water OLYMPUS DIGITAL CAMERAreservoir since I didn’t see a fortification that restricts water from flowing, thus making it a Dam. Its located near Fateh Jang just off the main highway that connects Rawalpindi to Fateh Jang. It takes around 45 minutes to reach there, we made it in 30 since there was no traffic in the morning.

The place was quiet and green, which to our advantage was good. The weather overcast and a good breeze made it a perfect setup for putting our lines in the water and wait. We picked up a spot and after setting things up, threw our lines in the water. No Luck. The fish took the bait but didn’t get hooked. This happened for the next three hours. We only managed to get one little fish out of the water, weighing no more than 100 grams. WE changed the spot still no Luck. At 12 we decided to call it a day for this spot since we had to visit two more places.

Next stop was Rawal Dam Spill way, which to me did not turn out the way I expected it to be. It was more of a swamp, with OLYMPUS DIGITAL CAMERAexcruciating smell of dead animals, mostly fish, making it hard to breath. WE surveyed the water, it was stagnant but shallow and we could see fish moving between tiny spaces. We tried, yet again the fish didn’t take the bait. “Typical Islamabadi” – as proclaimed by Shehzad Ahmed in his write up of the same event.  Since the size of the hunt was so small, we decided to skip this place and go to the third spot. Also there were mosquitoes and maggots all over the place.

Next stop, a place behind all the farm houses, just behind Margalla town off the club road. WE put our lines there with high hopes as people besides us were getting good results out of water. WE tried shallow waters, Deep waters – since you can make make your line go as far as you want if you have a good throw – No luck again. We found people talking about different medicines they used or some other special stuff to attract fish and concluded that it was probably one of the many reasons we could not get any meat out of water.

All in all it was a good outing. the weather multiplied the joy by many folds. We ended up at savor foods in the evening, tired and a little dejected. Everybody went to their homes and I slept the rest of the day.

P.S. Anyone going for fishing scene please do tag me along.

 

Tagged , , , , , , ,