So What’s Your Game Of The Year 2004?

Some excellent titles to choose from that make my shortlist (in no particular order):

  • Halo 2
  • Far Cry
  • Half-Life 2
  • Chronicles of Riddick
  • Joint Operations: Typhoon Rising
  • Project Gotham Racing 2

A good year…

The Guts Of PasteOff

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();


 



                  if(data.GetDataPresent(DataFormats.Bitmap))


                  {


                        Debug.WriteLine(“Bitmap present”);


                        this.icon.Icon = this.WithImage;


                        GetBitmapFromClipboard(data);


 


                  }


                  if (data.GetDataPresent(DataFormats.Text))


                  {


                        Debug.WriteLine(“Text present”);


                        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)


            {


                  Bitmap x;


                  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:



  this.theImage.Save(filename,System.Drawing.Imaging.ImageFormat.Jpeg);


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!

PasteOff Upload Script

This is a sample script that’s quite similar to the Upload.CMD I use with PasteOff (fixed the download links, by the way), to upload images to my blog site. 

Customize the variables at the top, and upload away…

As a note, it is really important not to have trailing spaces after the SET lines or after the Echo %VAR% lines – they’ll break it, and you’ll be wondering why…

—- Upload.CMD

@echo off
Echo Creating FTP Script
SET FTPHOST=ftp.example.com
SET FTPUSR=DOMAIN\USER
SET FTPPAS=password
SET FTPDIR=/BlogImages

echo %FTPUSR%> uploadfile.txt
echo %FTPPAS%>> uploadfile.txt
REM echo %FTPPAS%>> uploadfile.txt
echo CD %FTPDIR%>> uploadfile.txt
echo PUT %1>> uploadfile.txt
echo QUIT>> uploadfile.txt

Echo Performing FTP Upload
ftp -s:uploadfile.txt %FTPHOST% >> ftplog.txt

Echo Deleting Upload File
REM better to delete it than leaving more passwords lying around
Echo.>>ftplog.txt
Echo Deleting File >> ftplog.txt
Del uploadfile.txt >> ftplog.txt

PasteOff 0.7. Lots of tweaks.

Oops, it’s 1:45 am. Still, new version is baked, and it’s pretty much what I want from a utility thing.

Coolest new feature: now leaves a user-defined string on the clipboard. Also, stuff that 0.6 broke should work better.

Download on the PasteOff page.

Google now shows another PastePal; to avoid confusion, I’m going back to the original name.

Up, up and away. Did I mention “up”?

Off on vacation from 24th Dec to 10th Jan, so my last day of “real” work this year is tomorrow.

Thanks to all three readers (that’s 150% up on last year) for your comments, help, and occasional bouts of sanity. I hope you all have a safe and happy New Year, unless you don’t celebrate that sort of thing at this time of the year, in which case I’ll just look uncomfortable, shuffle my feet and try to change the subject.

Airzooka! Blup!

Ciao!

 

[Update] The roads North out of Sydney were packed to a standstill, blowing out a 7 hour drive to Coffs Harbour to nearly 14. The news told me that angry motorists demanded an apology from Transport Minister Carl Scully(TM), but I think I’ll just mention it and move on. Sigh.

My First Smartphone

Embracing the Christmas Spirit, I figured I’d get an i-mate SP3i from Telstra.

So far, I’m pretty impressed with it. I’ve sent a couple of blogs to my Spaces site via Activesync over GPRS, including photos (yep, my first camera phone). The quality of the photos is Good Enough for my blogging purposes (and better with stronger light), so if my girlfriend wants high quality photographe, she can bring the Real Camera…

I’ve been fiddling about with it, trying to get non-MID (I hate polyphonic!) ringtones onto it, and as it turns out it’s really easy – just plonk the WMA in the Storage\Application Data\Sounds folder, and there they are! W00t!

Now I just need that 256MB Mini-SD card to arrive so I can use it as my portable music player… come on… come on…

Um, I was just trying to work out how to take a photo of the phone using the phone. Time for bed.

Update: OK, chasing down and chopping up audio to make ring tones meant bed was a silly dream until now.

I’d been getting the message something like “unable to connect using your default connection, would you like to try pass-through?” very often when attached to the PC via USB, and it was driving me up the wall. Nickmac pointed me to one set of options, and the other is on the PC in ActiveSync Settings, on the Options -> Schedule tab, under the “Server Schedule” heading. I generally don’t want the phone to try to server sync when cable-connected (only Desktop sync, thanks), so I set that to Manually, and I haven’t been promped since.

PasteOff 0.6. More Image Formats.

PNG, BMP, JPG, TIF can be output. Sometimes they might even work, too!

As a note, when upgrading, previous settings aren’t migrated. I’m using binary serialization to store the configuration options, and when the format changes (eg, I add stuff), I break deserialization. (Shrug).

Download here.

More Fiddling: PasteOff 0.5

PasteOff is back, bigger, stronger and with more error handling. OK, barely more error handling. It’s a fun project, not a production one, mmkay?

PasteOff is a quick’n’dirty utility that saves images from the clipboard to a pre-arranged location in JPEG format, with a randomly generated filename (or one you specify), and can run a utility/script against the saved image afterwards.

This version (0.5) adds:
 – configuration UI – you can pick the folder the images are saved to
 – prompt before overwrite option
 – click the icon to check for an image on the clipboard (eg, you click once, the tray icon refreshes. Nice and easy.)
 – the ability to run a program after the image is saved: This happens automatically if a program is selected in the Configuration dialog), so you could run a script or EXE that takes the saved filename as its argument, and uploads it somewhere (that’s my intended use, anyway).

It’s still rough around the edges, and the usual “Please don’t sue me if something goes wrong” disclaimer applies.

[Update]: Moved the download to the new master article for PasteOff.

PasteOff: Clipboard-To-Image-File Utility

PasteOff


Strange New Disturbance


I’ve been testing PjPic, and it addresses many deficiencies of PasteOff (multi-profile!). If you like PasteOff, you might like PjPic more. Or as well!


Fiddling: PasteOff Image Saving Thing


As I mentioned in my post about MSN Spaces, I’ve got this weird habit of wanting to save and convert clipboard bitmaps (most often, OneNote screen clippings, which you take by right-clicking the OneNote tray icon) into JPGs or PNGs directly, with a minimum of actual effort expended.


So, I hacked together a little applet that converts any bitmap on the clipboard to a JPG, PNG, TIFF or BMP file in a configurable folder (configurable), and can optionally run a command against the saved file. You don’t need to worry about naming if you don’t want to.


I call the project PasteOff (say it with a Sean Connery accent).


Disclaimer: You assume any and all risks with using this software – it’s unsupported, largely untested, and isn’t production quality. It’s software I developed for my personal use, and may not be fit for any particular purpose other than my own personal use.


Download:  Latest Version  (0.8) , 13KB
.Net Framework 1.1 is required (get it from WindowsUpdate).


Installation: Unzip to wherever you want it. Then create your own shortcut to run it, or just run it directly. Simple, eh?


Configuration is stored in C:\Documents and Settings\Username\Application Data\PasteOff\config.bin .


Using PasteOff


It’s all run from a notification-not-system-tray Icon. This will be called “the icon” to avoid me having to type “notification” a lot.


Icon with image on Clipboard:     With no image on Clipboard:  


The icon doesn’t self-refresh, it only refreshes when you do something with it (like click it). Right-Click the icon for actions and Configuration options:



Typical usage works like this:



  1. Get your source image onto the clipboard with Ctrl-C, OneNote screen clipping, PrtScn, heck, any Copy will do.
  2. (optional) If you left-click the icon once, it should change colour to indicate an image is now on the clipboard. You don’t need to do this before doing anything else, it’s just a handy way of telling whether something’s there.

    • I just discovered that OneNote actually puts the image on the clipboard for you while taking a screen clipping, so thanks OneNote for saving an extra Ctrl-C. So, for me, step 1 is just Right-click the OneNote icon, choose Create Screen Clipping, select desired screen area.

  3. If you want to type a descriptive name for the file, double-click the icon to bring up the preview window (there’s also a context menu item for this). The extension is automatically supplied.

    • Obviously illegal characters are removed or replaced, but it’s not a competition to break it, okay?

  4. Otherwise, if you just want a random-ish name, right-click the tray icon and choose Save Directly. The file will be saved directly to the target folder, with a temp file name provided by Windows – usually something like TMP43a.jpg.
  5. If you’ve specified an application to run after saving and the save is successful, the custom app you specify is run against the file (including path) that was produced.

  6. Depending on your clipboard options, you can put the local path and filename, some custom text or nothing at all on the clipboard afterwards.

    • I use the custom text option: <img src=”http://www.example.com/%s”> so that I’m ready to post the image link directly into some blog HTML in .Text.

Notes:



  • The preview window tiles images, there’s no scroll bar, and images tend to linger even after being invalidated. I don’t really mind.
  • If nothing seems to be happening when you Do Things, the icon’s probably gone “blue” (eg, image is gone, text or some other non-image object is on the clipboard).
  • OneNote seems to store notes on the clipboard as images too! So you can make a JPG of note text, not that you’d usually want to…

Don’t forget to use the clipboard text (if you need to) before copying the next image to the clipboard.


On the cards for When I Feel Like It:


If there’s a bracketed version number in front of the feature, it first appeared in that version.



  • (0.5) Support for target folders other than My Pictures as a target! (very likely, very soon).
  • (0.5) Optionally run a batch file on the output. Makes my MSDN blog stuff easier if I do that…
  • (0.5) Optional Prompt Before Overwrite.
  • (0.6) Other image formats (Thanks for the suggestion Mischa)  now PNG, JPG, BMP and TIF can be done. 
  • Support for multiple “save profiles”, with different commands for each. Maybe. It kinda seems like the “20” part of 80/20.
  • (0.7) I’m sure there’s a reason you might not want the clipboard contents overwritten with the end filename. So perhaps turning it off might be an option. Sometime.
  • (0.7) Allowing user to specify the string they want on the clipboard

  • (0.8) Disable running a command directly from the tray menu \
  • Memory optimization – 0.8 is ~12MB from boot.
  • A little more robustness/user friendliness. Can’t hurt. Can it?
  • Optional re-numbering on attempted overwrite.
  • Base filename support (eg, all images are IMAGE000n or whatever).
  • Log/history/something. Maybe.
  • Preview window improvements. Maybe.

 

Fiddling: PasteOff Image Saving Thing

As I mentioned in my post about MSN Spaces, I’ve got this weird habit of wanting to convert clipboard BMPs into JPGs directly, with a minimum of actual steps expended.

So, I hacked together a little applet – let’s call it version 0.1 – that converts any bitmap on the clipboard to a JPG in my My Pictures folder. I like doing this kind of thing, it helps me relax.

I called the project PastePal, after considering PasteOff (say it with a Sean Connery accent, and you’ll understand why. Perhaps.).

Disclaimer: Don’t Ever Use This Software. It’s an Alpha. It might wipe out important images, and/or your hard drive. The risk is yours.

It’s all run from a notification-not-system-tray Icon.

The flow works like this:

  • Get your source image onto the clipboard.
    • I just discovered that OneNote actually does this for you while taking a screen clipping, so thanks OneNote for saving an extra Ctrl-C. So, for me, step 1 is just Right-click the OneNote icon, choose Create Screen Clipping, select desired screen area.
  • If you want to type a descriptive name, double-click the notification area (aside: maybe we could just bite the bullet and call it the tray like everyone else does?) icon to bring up the preview window.
    • The icon should change colour to indicate an image is now on the clipboard. Illegal characters are removed or replaced, but it’s not a competition to break it, okay?
  • If you just want a random-ish name, right-click the tray icon and choose Save Directly. A temp file name will be used.
  • All images go straight into the My Pictures folder. Not yet configurable.
  • In both cases, if the save is successful, the app puts the full path and filename of the saved JPG file on the clipboard, ready to be pasted into a web upload form or File Open box, or whatever.

 

Notes:

  • Saving overwrites without prompting. It’s an Alpha, don’t use a filename you’re likely to reuse or that is even remotely similar to other filenames when you remove the funny characters from it and replace spaces with underscores.
  • The preview window tiles images, there’s no scroll bar, and images tend to linger even after being invalidated. I don’t really mind. It should work OK for the next one.
  • If nothing seems to be happening when you Do Things, the icon’s probably gone “blue”.
  • Don’t forget to use the clipboard text before copying the next item to the clipboard.

On the cards for When I Feel Like It:

  • Support for target folders other than My Pictures as a target! (very likely, very soon).
  • Support for multiple “save profiles”, with different commands for each. Maybe. It kinda seems like the “20” part of 80/20.
  • Optionally run a batch file on the output. Makes my MSDN blog stuff easier if I do that…
  • A little more robustness/user friendliness. Can’t hurt. Can it?
  • I’m sure there’s a reason you might not want the clipboard overwritten with the end filename. So perhaps turning it off might be an option. Sometime.
  • Optional Prompt Before Overwrite.

PasteOff Download Page