Latest Posts


More Yahoo Weirdness. !

{ Posted on 7:46 PM by Vivek }


Do you ever feel “God, Why is this happening to me ?”. I do, in fact i felt like that a couple of minutes before posting this. Last time a different sort of YAHOO weirdness happened, again today i happened to be minding my own business and i was kindly notified (by digsby ..err…like that's important ) of an email which dropped into my mail box.


At this point i didn't notice it, then out of sheer curiosity i opened my inbox and was presented with this.(don't mind that i have 8000 unread msgs, most of it is crap.)



This isn't a big deal i know, so what if the FROM part is missing, but why should it. Am i being prank’ed ?

Earlier on i used send documents to myself, without a subject etc., and it used to look something like this, until it hit me hard on the head “well Duh….you could draft it..”

But that wasn't the case this time.

Ok lets lets carry on.

I opened the Message


Hmmm…No from, No to

and No this isn't spam.

But WAIT what’s that attachment thing “wpe6”, first i thought that it could be a virus, No it sure wasn't a virus. It was an Image.

And honestly this was it.



( Twitter? Damn, i should’ve known)


I wanted to dig in more so I had look at the Email Header


From nobody Thu Jan 28 13:02:14 2010
X-Apparently-To: via; Thu, 28 Jan 2010 05:09:14 -0800
Return-Path: <>
X-YMailISG: W1ZVn4wWLDuaFD1TxPEIySv8.o3XC1IZoWCQmLGjCyvBCWlyqtoMv0KWf2


a lot of signature here…

Content-Type: image/gif; name=wpe6
Content-Transfer-Encoding: base64
Content-Id: <>
Content-Length: 55297


I almost laughed when i read “from nobody”

I’m no email expert, but if you’re one. please do me a favor and explain, how could this be?

Am I missing something ?..

Until the next weirdness


A Free alternative to give your .Net apps a customized look and Feel - Using Component Factory Krypton Tool Kit

{ Posted on 10:51 PM by Vivek }
Tags :


I ‘ve been for a long time searching for a way to skin my applications and give them a customized look and feel. I know that its fairly easy in Java, but in winforms its a real pain in the rear. There are a lot of fancy and lucrative options available for doing this in .Net, but only a precious few are free, one of them is the Component factory’s Krypton Tool kit.  It took about 8 hours to come up with this . Actually a SO user called renick kindly pointed me at this wonderful component. I felt so happy that i thought, I’d share this little piece of info, hence this blog post.

First a little background on the Krypton Tool Kit. Its part of the commercial Krypton Suite from component factory. While the suite itself costs a fortune, the tool kit is free. Which is sweet, because that means the basic UI elements such as the Text fields , and combo boxes are free.

You can get it by visiting

You’ll have to register with your email ID, which sucks I know, but trust me its worth it.

I assume that you are familiar with Visual Studio ,.Net and  the standard drills such as adding references etc.,

Once you’ve downloaded the suite (along with the toolkit)


and installed it.

You’ll have free access to the tool kit.





you get the idea ..

The full suite features

The office Ribbon Control

and the fancy stuff are trial only


which consequently means

your UI changes from Being boring like this


To looking good like this


The catch here is that the Ribbon part is licensed commercially (though its free for trial), but there are a lot of free versions of “Office Ribbon” like controls out there.

But all other controls are free.


How do I do It

The easy way is to Create a New Project,

since it provides some nice project templates


But the problem is the Templates vanish once you’ve uninstalled the trial.

So here’s a little hack to get the Tool Kit Assembly

The assemblies are not placed in the Global Assembly Cache, instead at  (You know where):\Program Files\Component Factory\Krypton Toolkit 4.1.1\Bin\

like so


You may copy the Tool kit Library, since it’s license is free.

(Note: after acquiring the library, you may as well ditch the installed software.)

You can place the assembly where ever you like and add reference to your heart’s content.



Now as you’ve probably noticed this tool box section doesn’t feature a form (nor does the standard tool set)

For that you have to inherit your normal form from the class



using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
namespace WindowsFormsApplication
    public partial class Form1 : KryptonForm

        public Form1()




To change the theme of the form and its child element theres a component called KryptonManager in the Tool Box

which provides a property (enum) called


which can be set to any one of the following


The one that was immediately interesting to me was the “Custom” option.

The Palette (in this context it means, a definition of “what” should be in “what” color) Definition for each theme is defined as a KryptonPalette class.

The component features a design time functionality, using which we can export the theme or import custom ones as plain XML files.


I encourage you to experiment with the custom theme , because that's where you can do some serious damage !

Chow !


The Perspective “we” all miss…

{ Posted on 9:32 PM by Vivek }
Tags :


This is my second purely non technical post since my first one.  I like writing applications and also using them. But I as a .. ahem.. developer, miss being “the user”. What I mean is that I completely forgot the “user only perspective”. Think about facebook or orkut. If you’re a normal user, you’d think about “doing what they were meant for” messaging and scraping and chatting and all the good stuff, but if you’re developer you would wander off into a dream that only a software geek understands. As for me, I’d think of the AJAX UI, JavaScript, I do use them, but the essence of wonder, the surprise is spoiled. Much like a magic trick, If you know how its done you’ll loose the element of bewilderment (going insane and saying ”its freaking awesome” ).

I think when it comes to software, that is one of the things that drives a developer (IMHO of course), i.e we developers don't stop at saying “who cares as long  how it works ”, we do care. Well I don’t mean to say that Non-developers are ignorant its just that they don’t fit in very well. Again I mean no offense to the non-developer community. Its like I wondering how a particle accelerator like CERN work. I mean the wonder and  the surprise I have hearing about it stays that way, one day if I know a respectable amount (though very very unlikely) of information about the CERN, may be i wouldn't be so awed at hearing facts those mind blowing facts about it.

I just cant imagine the sense of amazement i would have if i had no clue about how Microsoft-Touch works and I get to use it for the first time.Hmm. Like I said I don’t know. You have to be a complete user to understand it. Oh i wish I could.

At the same time imagine you’re with a non-developer friend and you’re Burning a CD, as the progress bar, progresses (pun intended), suddenly he cant stand it any more and he tells you “why don’t they make it faster by allowing us to drag the progress bar”, thinking about slide controls or scroll bars. Now those are the kind of situations where you feel a tad more grateful for being a developer. :)

Another instance is where another friend of mine got excited, and asked me if i can write a program for quickly charging his laptop. They’re not being ignorant they’re used to “free lunches” like that. Its our fault.

Either way its a different deal being a developer, I love it absolutely but the thing is this mysterious longing to be a complete computer novice   again. May be I’m being a little spiritual here, but hey,I’m being honest.Personally I think being a developer is being a magician (a conjurer if you’re British). Fellow magicians can sometimes surprise each other, but they usually work out the mechanics. But  a user in many ways are like the spectators. They simply have more fun.

I definitely miss those days, when using MS paint was a trip to Disney land,

as my uncle once commented on seeing his son Alex going wild painting on MS Paint.

”hey, don’t use up every bit (of paint ) leave some for tomorrow”

Developing an Application, with C# , a bag of chips..and .....a Profiler !(updated)

{ Posted on 11:54 PM by Vivek }
Tags :

My previous post was about a solution to Bloaty Digi-cam photos, since the solution itself was a little tiresome to carry out manually, and there seemed to be no way to automate the process, I decided to do some good in the world, by writing a small application that would do that. Folks I a newbie to software development, and I know how amateurish the whole thing looks, as i write more and more code the more experienced I become,much like a pilot, the more he flies, the more he gains. But not every minute of his flying counts, there will be some tumbling and fumbling in the beginning. The same (I believe) applies to coding, not merely the lines of code,but  the quality of it. You’ll soon see where all this corny talk of mine leads to.

My delusion on the “Apparent success”?
How long did it take to write this app?

Well, an afternoon, by my standards that’s remarkable(actually remarkably deluded), I said to my self, but as my application went to the testing department, everything went down the trenches. The rest of this post is my interesting journey… “Developing an Application, with C# and a bag of chips..and .....Oh a Profiler”

As usual I fired up visual studio, I not a Microsoft shil, but I’ve got to say that in my book there’s no software development without VS.

Then I phrased the problem in my mind, I need to somehow replicate whatever MS Paint is  doing to reduce the size of the images. You’ll find it weird as I did, when you’ve read my previous post. Because effectively what paint was doing we just saving the JPEG to JPEG, no format conversion, re-coding , no rescaling , but it did change its resolution, but only a little.

So in order it achieve that I just have to Load the JPEG image and save it to a file stream again. Seems simple enough.

For those of u from Java background, in .net there are a lot of Nifty classes to play around with Images, using which i can save to and read from many formats Jpg,Bmp,tiff, etc..,The problem was it didn't quite have the effect of MS paint. The file size was still sky-high. So I remembered about the FreeImage library, which i thankfully heard about a year ago. I forgot all the documentation, but it was easy the only problem was it was an unmanaged (ie non- .net ) library, so there is a magic called P/Invoke involved in using a non-managed library, from a managed framework. I know how java programmers feel about this, but dont forget there are a lot of performance incentives involved with a little pain incurred, by writing a wrapper to the non-managed libraries such as FreeImage. Any way I ended up writing a C# wrapper to two important function i needed from the massive 2MB library.

They were

public static extern int FreeImage_Load(int format, string filename, int flags);
public static extern bool FreeImage_Save(int format, int handle, string filename, int flags);

the parameters are self-explanatory, int format is the file format for Jpeg it was 2,


I implemented these things with the following function

public void SaveToJpegOptimized(string UnOptimizedFile,string OptimizedFile)
int a;
a = FreeImage_Load(FIF.FIF_JPEG, UnOptimizedFile, 0);
FreeImage_Save(FIF.FIF_JPEG, a, OptimizedFile, 0);

catch(Exception exp)
System.Windows.Forms.MessageBox.Show(@"Houston we have a problem " + exp.Message.ToString () );


Actually there was another function which the application critically needed. More on that later.

Apparently All I had to do was Load the Jpeg and save it.So the logic was sketched. Now coding time…

Some people are religious about whether they should design the UI and code or backwards. I figured out it was better to Design the UI since the application logic was pretty much completed.

so here it is. the  completed UI


I could’ve done this a little professionally, but i wanted it to be intuitive and not intimidating for non-geek users. Since were talking about talking to the Hard Disk (pun intended), I decided to go for Asynchronous operation, and It paid off. Especially when the user chooses to operate on multiple files. And with the Minimize to tray option the app sits quietly and does the job on the system tray.

Everything was going great until i decided to put the app to the test.

I mercilessly made it to chew on two hundred files


The application before eating the 23rd file, drank  440MB of Precious Memory.

I smelled MEMORY LEAK….

It was time to call the super hero at times of such peril.

TADA the Profiler, a blessing to the developer,

It quickly showed me where I went wrong Of course an experienced developer would a found out the cause in a snap,but it proved difficult for me.

The cause of the application to consume that much memory was that i forgot to call an important function.

public static extern void FreeImage_Unload(int handle);

The FreeImage_Unload(int handle) de-allocates the memory needed to hold the image in memory.

private void Folderworkermethod()
string[] files = Directory.GetFiles(textBox2.Text, "*.jpg", SearchOption.TopDirectoryOnly);
DirectoryInfo drin = new DirectoryInfo(textBox2.Text);

FileInfo fileinfo;
progressBar2.Value = 0;
foreach (var file in files)
fileinfo = new FileInfo(file);
oldfoldersize += fileinfo.Length;
progressBar2.Maximum = files.Length;
drin = null;

oldfoldersize = oldfoldersize / 1024;
lblfoldersize.Text = oldfoldersize.ToString() + "KB";
string tname = "";
this.img = new ImageUtil();
progressBar2.Step = 10;
int filecnt = 0;

foreach (var file in files)

tname = file + ".temp";
if (File.Exists(file + ".temp"))
File.Delete(file + ".temp");

File.Move(file, tname);

img.SaveToJpegOptimized(tname, file);
tname = "";
progressBar2.Value = progressBar2.Value + 1;
lblfilecnt.Text = "File " + filecnt + " of " + files.Length.ToString();


foreach (var file in files)
fileinfo = new FileInfo(file);
newfoldersize += fileinfo.Length;
newfoldersize = newfoldersize / 1024;
lblfolderafter.Text = newfoldersize.ToString() + "KB";
lblfoldersizesav.Text = (oldfoldersize - newfoldersize).ToString();
img = null;
files = null;
catch (Exception)



At line number 35 you can see that after a file has been processed the memory can be reused, which the application failed to do.

The code

public void SaveToJpegOptimized(string UnOptimizedFile,string OptimizedFile)
int a;
a = FreeImage_Load(5, UnOptimizedFile, 0);
FreeImage_Save(5, a, OptimizedFile, 0);

catch(Exception exp)
System.Windows.Forms.MessageBox.Show(@"Houston we have a problem " + exp.Message.ToString () );




public void SaveToJpegOptimized(string UnOptimizedFile,string OptimizedFile)
int a;
a = FreeImage_Load(5,UnOptimizedFile, 0);
FreeImage_Save(5, a, OptimizedFile, 0);

catch(Exception exp)
System.Windows.Forms.MessageBox.Show(@"Houston we have a problem " + exp.Message.ToString () );


That’s right all it took was a single line extra. 8

Folks this is the side effect of managed programming The GC cannot interfere with the unmanaged code region, in C++ as we all know it is left to the coder to dispose all the objects with the( long forgotten )Destructor.(the nostalgic memories may return to haunt you :) . Any way That was it instant cold relief, I mean instant relief from Memory leak.I prescribe a good dose of profiling and experimentation.

Hope the boredom didn't kill you :) .

Until the next adventure


A Solution to Bloaty Digi- cam Photos

{ Posted on 6:19 PM by Vivek }

I remember once, when I had to scan 10 or so certificates and photos, and had to E-mail them. As i was uploading them i hit the ceiling of 10 MB quite soon. About the third or fourth picture. I wondered why and as i saw the size they around 2-3 MB . Easily 4 Photos would’ve been enough to reach the 10MB limit. Unfortunately I couldn't “Google” for the lack of time. Then I sort of opened one of pictures with paint (accidentally by clicking “Edit” instead of “Open” in the Explorer context menu). Then I thought I would save the picture to another folder, that would be like copying the same file to another folder.Ok. Not quite. Something interesting happened. The file size was reduced by 70 %. I didn't notice this at first. But I did eventually. Then I repeated it again, with another pic. And ended with a smaller file size.

You dont have to take my word for it

see for yourself

1.98 MB 2592 X 1944

Bloaty Picture


523 KB 2592 X 1944

Same picture, Smaller Foot Print


That’s roughly 75 % saved without any noticeable difference.

Well if you are a picture lover and have a lot of photos taken with Digi-Cams. You’ll find this, easy on the Hard disks. Ahem.. a little math. Say you have 100 photos with a average file size of 2MB per photo you need .about…? that's right 200MB how much is 75% of 200MB .150MB saved. If you have 1000 photos with 2M average you can save 1.5 GB.Note that I’m being pessimistic, actual results may be greater. On the other hand some times the size may actually increase, a little bit ( 5 – 10 KB).


There’s just one catch, you can’t automate (at least as far as i know), paint to do this. So i decided to write a tiny app. That’ll do just that. Actually it doesn't use paint. It uses the infamous FreeImage library.

The following is about the Nitty –Gritty details of the application itself. If you dont like the sound of it just

download the Application here

I just call it the Jpeg Optimizer

Also note: Even though the application does not rescale the image, it does change its resolution but only a little, no noticeable difference unless you choose to zoom 200-500X.
The application does not feature a "backup the images" facility( for now).


The software is provided as is, without any warranty. I cannot in any way guarantee the correct functionality of the software. The software is free to use copy an distribute as long as it is intact.

Copyright Notices:

FreeImage Is an open source library maintained by Hervé.Under the GPL license.


The application is built on the .net framework, in C# language. I intentionally decided to target the 2.0 Framework, since many people dont have .net 3.5 installed. Besides I had everything to get going in .net 2.0.The app is multi-threaded for a responsive UI.

More about the application on the next post.

Weird Yahoo Server Response..

{ Posted on 3:04 PM by Vivek }

I seriously dont mean to be off-putting,but this post contains Extremely Boring Geek content..

I should’ve probably tweeted this,its a bit large , to be considered as a micro blog.Any way i was checking my email the other day, i happen to use yahoo among other mailers. As I was about to clear my spam folder , the whacky AJAX UI , did something weird .

Take a look at this,

No its not the regular 404 ”not found” its says 502 “Cannot Find server Or DNS Error”.

Also it gives me instructions to go to the Help -> About. ok…then again where can i find About Internet Explorer in Firefox.

Its either something’s going on there between,Yahoo and Microsoft or Yahoo’s server just assumed that everyone would probably use Internet Explorer (which is so untrue).

But is it Yahoo’s fault,if not, I have a hard time imagining Firefox doing that. Cause Firefox uses Gecko Engine, Microsoft uses well …How the heck do I know). I’d put my money on Yahoo doing, that cause , isn’t it the servers responsibility to handle these kind of errors..

Feel free to enlighten me dear readers..

If you feel like, “Big Deal”, after reading this

I warned u…:)

I have a bunch of freaky, bugs, errors or goof-ups, just like this one..I’ll post them soon.

Let there be Blog !

{ Posted on 9:56 PM by Vivek }

My first..err.. encounter, (if you will) with the word “blog”, was a year or two ago. And it took me a month to “understand” that it was just a fancy word for writing articles (in the cloud).

I also realized, that just because i’m  following technical blogs, doesn't mean Blogs were meant for technical stuff. There are a lot of non-technical yet great blogs. I admit that , initially i found it outrageous,and whenever i ran into a blog I was like “who would want to read a monologue of someone, I'd rather spend the time doing something else”. I changed that opinion soon enough.

But some blogs that i read are highly biased,and that's not how articles are supposed to be. (or do they). Some are really worthwhile like

this one by my cousin brother. and this one by my cousin sister,

(I find innovative ways to flatter people)

Some general , and some blogs exists just to rant their Ex-Employers Here’s one GUY. and here’s the proof that he is so. listen to his podcast,

And boy, is he obnoxious, if i knew English better i would‘ve found a better word for this guy, sheesh , makes me wanna punch him.

Either ways it seems  to me that “blogs are supposed to reflect what you think and feel about what you actually want to blog in the first place“

(feel free to comment, critique or rant about this statement made by “yours truly”)

Er..I know..I feel like an idiot ..because I'm blogging about blogging.

(C’mon folks, its my first blog so cut me some slack..)

Anyway , i have decided to give it a try myself. And viola here it is.

Disclaimer: if you are offended , or you have a bad-hair day or feel dizzy  after reading this I’m not responsible.. Kidding..thought it’d be cool to have a disclaimer.

And being a self-proclaimed geek, my subsequent blogs will be considerably, geeky occasionally General. I'll definitely find a balance. Any way dear reader Keep reading.

bye for now.

Tweet Me at:@vivekbernard

E-Mail me @ vivek[dot]bluestar[at]