Ahh, my first day off. Just catching up on blogs, editing theme tunes for the Smartphone (heheh Knight Rider), playing a little Chronicles of Riddick... it's all fun. No family commitments until this evening. Sweet. Oh, and repeatedly trying to get the code samples below pasted in. Nnnngh. Sorry if this is the 18th time you're reading this.
I've been asked about the source code for PasteOff a couple of times. As usual, it's embarrassingly poor, so I figured I'd walk through the interesting bits and ignore the terrible UI code (just wait for the Avalon version! I'll make sure it has a gradient somewhere and takes 30 seconds to materialize*).
The clipboard handling is ripped straight from the MSDN library IDataObject help (though I can't actually find the same entry in the online help):
private void GetCurrentClipboardImage()
IDataObject data = Clipboard.GetDataObject();
this.icon.Icon = this.WithImage;
this.icon.Icon = this.NoImage;
And that's the guts of the clipboard handling. Nice and simple.
The image handling in GetBitmapFromClipboard is a doddle too:
private void GetBitmapFromClipboard(IDataObject data)
x = (Bitmap) data.GetData(DataFormats.Bitmap, true);
this.theImage = x;
(theImage is a System.Drawing.Image).
And the Image class has a ridiculously full-featured Save method, perfect for format conversion:
As a mention, Darryn wasn't exactly glowing about the JPEG image quality when he was fiddling with his own saving routine. I avoided that with a choice of formats, but if anyone has suggestions for improving JPEG quality in .Net, I'm sure either of us would appreciate the tips.
So there you have it - everything* you need to build your own image conversion utility. Enjoy!
Chronicles of Riddick is my pick for #2 FPS of the year after Far Cry. Amazing sleeper title. Essential for anyone even remotely interested in FPS games.
I guarantee you'll love it.
It's pretty good so far - it has much the same look as the movies, which is a Good Thing, and the sound is also superb.
I think I'm going to have to go back and play Far Cry again after this - it was also excellent.
I'm glad you changed the name. PasteOff in the Sean Connery accent I hear in my head makes it sound funny and catchy.
I'm glad you gave out this little tidbit because this is one of those projects "I can do"tm. I have so many thoughts and brainstorms on seemingly complex stuff and then I realize that I could do easy or easier stuff and it would be a little more satisfying than spec'ing stuff 98% of the time with little or no code involved (yet).
Keep up the good work. I haven't bothered trying to think of a way to make it better because every update you do seems to include the ideas I come up with. That's one clue that tells me when to stop thinking.