Exploding Images with Photoshop Elements

Dalby Forest Fence

Every now and then I fall over hilarious bugs that really shouldn’t be out there. It kind of cheers me up. I’ve never written software with holes like these, and they are selling theirs as product.

I’ve found a truly smashing one in Photoshop Elements. I have a love-hate relationship with this program. I stick with it because it does what I want eventually and I can’t be bothered to learn another program. I have the feeling that it could do pretty much anything, although I also have the feeling that I’ll never figure out how to use it.

Anyhoo, the bug/feature has to do with bulk processing of images. I’ve started reducing the size of my pictures before I send them to Flickr so that they don’t take too long to transfer. I make them 1500 pixels in width, which seems to work OK. I did one batch, and then tried to do another.

And my machine stopped. For quite a while. Eventually I killed the Photoshop export and tried to figure out what had happened. Turns out that the program remembers the number that you enter to resize your picture, but not the units. The program was busily creating a bunch of images 1500 cms wide. Or around 450 feet. This begs several questions.

  • Why does it just remember the number?
  • Has anyone ever really needed to produce a picture that big?
  • Did anyone ever test this?

Oh well.

Wacom Bamboo Fun and Games

Lights

I didn’t actually buy much yesterday at the Gadget Show. Just a pair of enormous headphones from Sure that sound amazing (I daren’t tell number one wife how much I paid for them but they were heavily discounted) and a Bamboo Fun graphics tablet. They had them at 20% show discount and although they didn’t have any left to sell I was able to order one for home delivery the following day. I was thinking “Yeah, right.” as I gave my details, but the company were as good as their word and the tablet arrived today.

The thing about the Bamboo fun that had me most interested was that it supports multi-touch input as well as pen based control. It turns out that multi-touch is indeed supported, but not in a proper Windows 7 way. The Windows 7 touch API is designed for screen only use, there is no support for multi-touch tablet input in the operating system. Instead the tablet driver produces cursor and keyboard commands that allow you to do things like pinch zoom in compatible programs.  This means there is unfortunately no way you can use it for things like the Windows Phone emulator, where multi-touch input would be very nice. I’m not that bothered though, the device comes with a very good software bundle including a free copy of Photoshop Elements 7 and it is a nice tablet with a responsive pen which will make image editing easier.

Processing Lots of Files in C#

4346439556

Elliot came to see me today with a need to process a whole bunch of files on a disk. I quite enjoy playing with code and so we spent a few minutes building a framework which would work through a directory tree and allow him to work on each file in turn. Then I thought it was worth blogging, and here we are.

Finding all the files in a directory

The first thing you want to do is find all the files in a directory. Suppose we put the path to the directory into a string:

string startPath = @"c:\users\Rob\Documents";

Note that I’ve used the special version of string literal with the @ in front. This is so my string can contain escape characters (in this case the backslash character) without them being interpreted as part of control sequences. I want to actually use backslash (\) without taking unwanted newlines (\n)

I can find all the files in that directory by using the Directory.GetFiles method, which is in the System.IO namespace. It returns an array of strings with all the filenames in it.

string [] filenames = Directory.GetFiles(startPath);
for (int i = 0; i < filenames.Length; i++)
{
   Console.WriteLine("File : " + filenames[i]);
}

This lump of C# will print out the names of all the files in the startPath directory. So now Elliot can work on each file in turn.

Finding all the Directories in a Directory

Unfortunately my lovely solution doesn’t actually do all that we want. It will pull out all the files in a directory, but we also want to work on the content of the directories in that directory too. It turns out that getting all the directories in a directory is actually very easy too. You use the Directory.GetDirectories method:

string [] directories =
          Directory.GetDirectories(startPath);
for (int i = 0; i < directories.Length; i++)
{
    Console.WriteLine("Directory : " + directories[i]);
}

This lump of C# will print out all the directories in the path that was supplied.

Processing a Whole Directory Tree

I can make a method which will process all the files in a directory tree. This could be version 1.0

static void ProcessFiles(string startPath)
{
   Console.WriteLine("Processing: " + startPath); 
   string [] filenames = Directory.GetFiles(startPath); 
   for (int i = 0; i < filenames.Length; i++)
   {
      // This is where we process the files themselves
      Console.WriteLine("Processing: " + filenames[i]); 
   }
}

I can use it by calling it with a path to work on:

ProcessFiles(@"c:\users\Rob\Documents");

This would work through all the files in my Documents directory. Now I need to improve the method to make it work through an entire directory tree. It turns out that this is really easy too. We can use recursion.

Recursive solutions appear when we define a solution in terms of itself. In this situation we say things like: “To process a directory we must process all the directories in it”.  From a programming perspective recursion is where a method calls itself.  We want to make ProcessFiles call itself for every directory in the start path.

static void ProcessFiles(string startPath)
{
  Console.WriteLine("Processing: " + startPath); 

  string [] directories = 
                  Directory.GetDirectories(startPath); 
  for (int i = 0; i < directories.Length; i++)
  {
    ProcessFiles(directories[i]);
  }

  string [] filenames = Directory.GetFiles(startPath); 
  for (int i = 0; i < filenames.Length; i++)
  { 
    Console.WriteLine("Processing : " + filenames[i]); 
  }
}

The clever, recursive, bit is in red. This uses the code we have already seen, gets a list of all the directory paths and then calls ProcessFiles (i.e. itself) to work on those. If you compile this method (remember to add using System.IO; to the top so that you can get hold of all these useful methods) you will find that it will print out all the files in all the directories.

Console Window Tip:  If you want to pause the listing as it whizzes past in the command window you can hold down CTRL and press S to stop the display, and CTRL+Q to resume it.

Links for Software Engineers

Pot Pourri

I was talking to our .NET Development Postgrad students and we decided that there were a few things that you should be familiar with if you want to become a “proper” Software Engineer. These are the things I think you should do:

Read “Code Complete 2” by Steve McConnell. Perhaps the best book ever on software construction.  Then keep your copy where it is handy, and have a policy of reading a bit now and then, just to keep up to speed. If you can track down a copy of “Rapid Development” you should read this to.

Read I.M. Wright’s “Hard Code” blog. And buy the book if you like.

Read “How to be a Programmer”. Excellent stuff.

This is not everything you should do. There are other good places to look. But it is a start. Oh, and if anyone out there has other ideas about good, pragmatic texts for budding coders, then let me know and I’ll add them.

Christmas Chumby

4269183539

My “big” Christmas present to myself was a Chumby. This is a fun little internet appliance that you can write programs for.  I’ve started doing just that, and you can find out more at my newly minted Chumby pages.

Windows 7 God Mode

The internets are alive at the moment with discussion of the newly discovered ‘God Mode” for Windows 7. To take part in the fun, create a folder with the name:

GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

The folder magically becomes a “one stop shop” for all the Windows 7 control panels. I don’t think it lets you do anything you couldn’t do before, but it does put lots of useful things in one place.

isobuster for your Dreamspark Images

4138029641

If you are making use of your Dreamspark access to get hold of lovely free Microsoft software then you might have noticed that a lot of the good stuff arrives as ISO disk images. The idea is that you burn these images to disk and then install the software on them.

However, if you have a netbook with no CD-ROM drive, or are simply in a hurry I can recommend IsoBuster. This tool lets you copy files from ISO images onto your hard disk or memory key so that you can install programs from the disks without needing a physical disk.

There is a copy you can pay for, but I’m told that the free version will do all you need to get hold files from a disk image. IsoBuster is also useful if you have a damaged disk that you need to recover.

Gain Weight with Live Mesh

4119845964

I really like Live Mesh. This is a Microsoft file synchronisation thingy where selected folders on your machine are reflected onto the Live Mesh storage out in the cloud, and also onto other machines that run the Live Mesh add-in. It runs quietly in the background and doesn’t seem to intrude much on normal life (unless you are daft enough to make changes to files on two different machine before connecting them both to the network – at which point you will have to resolve a bunch of conflicts).

I’ve got all my courseware for the current year stored on Live Mesh. You get up to 5G of space on the server behind the system and this is plenty for a year’s worth of PowerPoint slides and Word documents.

The really good news for me is that I now no longer care which machine I’m using. As long as I allow it a few minutes to “catch up” with the latest versions (if I’ve not used that particular machine for a while) then I can use any device. The net result of this is that I no longer carry the same laptop to and from work.

I guess I could have used an external drive for this, but I’m always afraid of dropping/losing/having stolen the device which holds the only copy of my stuff. Live Mesh means my data is held on multiple machines, as well as on the central server.

However, my bag is now much lighter and easier to carry, and this means that I’m missing out on some exercise and will probably gain some weight as a result.

But I reckon it is worth it.

What?

I’m collecting stupid error messages. This is one of my favourites:

image

Every time I see it (which is often because our eBridge system has some links to insecure pages in amongst its https) my brain does a double flip as to what it might mean. Show someone that message and ask them which of the buttons is the dangerous one and I’ll bet they’ll look at you as if you were from Mars. Why can’t they just say:

image

The “Ultimate Steal” is Back

If you are a UK student I have some very good news for you. The Ultimate Steal is back. This is a deal from Microsoft that puts its software into your hands at less than video game prices.  You can get Office Ultimate for 39 pounds and Windows 7 Home Premium for 30.

Well worth checking out.

http://www.microsoft.com/uk/education/studentoffer/default.aspx

Dreamspark Goodies

Andy pointed me at a feature of Expression Web that does a similar job to the Balsamiq user interface designer:

http://www.microsoft.com/expression/products/Sketchflow_Overview.aspx

I had a quick play and you can make diagrams and design the navigation between the forms in your use interface. However, I found it a bit more complex to use than Balsamiq (although it has to be said that it does an awful lot more, and actually lets you construct the interfaces as well as play with them).

For students the interesting thing is that it is available for free from DreamSpark:

https://www.dreamspark.com

If you are a student on an academic course (and have an Athens username to prove it) then you can get hold of all kinds of goodies here, including operating systems and Visual Studio.  You can even get XNA Creators Club memberships so you can deploy your XNA programs to an Xbox 360. Well worth a look.

Windows Live Mesh Rocks

I’ve been using Windows Live Mesh now for a while and I must admit I love it. I now no longer have to bother about keeping files on my various machines up to date. I just have a couple of Live Mesh synchronised folders and I lob all the important stuff into there.

Live Mesh gives you on-line storage that is synchronised to the hard disk of one or more computers. Each computer runs the Live Mesh software which makes sure that whenever you change a file on one of the machines the copies on the other devices are automatically updated next time they connect to the network. It even provides a log of your activity, so you can track back what you have been up to.

Now, when I take my portable along to a lecture I don’t have to worry about putting the latest presentations onto it because I know they are already there. If I forgot the machine completely I could even use a web browser to pull the files off the Live Mesh online storage.

You get 5Gbytes of storage for free, and that is more than enough for a year’s worth of lecture notes and other teaching stuff. In fact, the service is so good that I’d pay to have more than that. If there was an annual subscription like I could put all my important stuff out there and I’d be happy to pay for that.

For students I can’t think why you wouldn’t use it. It would mean that you never lost your notes or programs, even if someone made off with your precious laptop.

Find out more at:

https://www.mesh.com/welcome/default.aspx

Hull Digital

I’m really pleased to find out that there is now a Digital Community in Hull:

http://hulldigital.co.uk/

They are organising a live event in October which has some interesting speakers:

http://www.hdlive09.co.uk/

I’ve persuaded my boss to pay for a ticket, and I’m really looking forward to it. I’m pleased to find that they do student pricing for the event (which seems to me quite reasonable) and with a bit of luck we can involve some of our students in their events in the future.

One of the most important things about computing is that the field is constantly changing and professional development is something you really need to work at if you want to keep your skills up to date.  Hull Digital looks like it will be a neat way of doing this.

Windows 7 Media Centre

We put Windows 7 on the Media PC today. I got hold of a 1 Terabyte hard disk, slapped it in a spare drive bay and left the machine to get on with it while we went out shopping. When we got back the system was pretty much sorted and except for some kerfuffle with the (now very old) TV tuner cards that needed some blast from the past drivers the install went very smoothly.

It works a treat. I was looking forward to some tweaks to the Media Centre and I wasn’t disappointed. It now supports digital Teletext, which is great, and it also has some really neat user interface touches. My favourite is that when you move through a recorded programme you get a little thumbnail of the image at that point in the show.

Windows 7 provides the speedup that I was expecting (which is nice) and the whole thing has given my two and a half year old media PC a new lease of life. I’m actually bringing machines out of retirement so that I can put Windows 7 on them and make them useful again. My old Toshiba Tablet loves Windows 7 and I’ve persuaded the boss to buy me a new battery for it so I can take it on the road again.

There was a tradition that new versions of Windows drove hardware sales, as people upgraded their machines to cope with the demands of the new operating system. Whilst it is always nice to have a new machine (I love shiny boxes) I think this time you won’t have to. In fact the upgrade will feel like a real upgrade (which I guess is how it is supposed to be).

The good news for students is that the Microsoft Academic Alliance version of Windows 7 being given away free is the Professional edition, which includes the Media Centre component.  Previously students were given the Business edition of Vista, which didn’t have media centre support. If you are lucky enough to go to an institution which, like the University of Hull, has joined the alliance then you will be able to get your own free copy of this rather nice operating system.

bing in Quite Good Shock

Google is a verb. It means “to search for on the internet”. Perhaps one day it will also mean “to take over the world”. Perhaps not.

Anyhoo, like everyone else I’ve used Google for all my searching needs since forever. Today I had a go with the Microsoft competitor, bing. I’d heard nice things about it, and so I thought I’d give it a go. And the big surprise is that it is actually quite good. I’m not convinced it is as good as Google for everything, but it is certainly good enough to make make wish I had two search boxes on my browser toolbar, one for Google searching and another for Bing. The two actually complement each other quite nicely.

Bing is good for entertainment and travel, and displays its home page and the search results with a graphical pizzazz that Google lacks. Google is good for stuff a bit more off the beaten track and does maps better. But it is nice to see some proper competition in the search arena.

Breaking Changes in XNA 3.1 SoundEffect

I hate breaking changes. They are like getting into your car and finding that the steering wheel is now the gear lever, and the seats are facing the other way.

Generally speaking the people who make the software try to avoid them too, which is as it should be. But every now and then they make the judgement call that somebody else’s pain is worth their gain, and so they go and move the universe around a bit.

They have done it with the move to XNA 3.1 from XNA 3.0. XNA 3.0 introduced a new SoundEffect type which made it much easier to make sound. Unfortunately, in its original incarnation this type also made it easy to inadvertently make sound that stole all the sound channels by mistake, and so they have fixed this in version 3.1.

Essentially, in XNA 3.0 the SoundEffect.Play() method used to return a reference to a SoundEffectInstance object, that you could then tweak to change some of the properties of the playing sound. This was kind of neat, except that if you ignored the return from Play it meant that the SoundEffectInstance that was created ended up being left hanging around, probably hogging a sound channel, until the garbage man got around to killing it off. If your game was well designed and looked after memory properly this may not happen of course, and so you would run out of sound channels for no good reason.

In XNA 3.1 the same Play method returns something different. It just sends back a boolean value that indicates that the sound is playing correctly. To get hold of a SoundEffectInstace you have to call the aptly named CreateInstance method on your SoundEffect. All very sensible, and much less likely to hog all the sound channels.

However, if you have just written a book which carefully describes the way that XNA 3.0 works in this respect (just like I have) then you are left wondering why they didn’t add an extra method (perhaps called QuickPlay or something) and leave the old Play intact…

Oh well.