<< May 2006 July 2006 >>

Thursday 29 June, 2006
#

At the start of the week, we had a bathroom and, seperately, a loo. Now we have neither, just a big space where they used to.

Oh, and dust. Lots and lots and lots of dust. It's on every surface, in every crack and crevice. It swirls around your feet as you walk, and is forming dunes along the hall.

Gah.

smellygit said I thought having them separte was supposed to be a good thing? Or am I living in the past? [added 30th Jun 2006]
I think you don't have children :)
The bathroom was really rather teeny-tiny. Once the dust has settled, been hoovered up, settled again, re-hoovered and then settled, it should be really rather keen and comfy. [added 30th Jun 2006]
Pete Ashton said You forgot how it gets up your nose turning your snot brown. [added 1st Jul 2006]
... in every crack and crevice ...

... I'm still digging it out now ... [added 1st Jul 2006]
Pete Ashton said Hmm. I never think of my nose as a crack nor a crevice... [added 1st Jul 2006]
Well, I'm delighted I've been able to help you expand your bodily horizons. [added 3rd Jul 2006]

[Add a comment]
Monday 26 June, 2006
#

Moseley Masterteam this evening. I believe I am the first two-time winner :)


[Add a comment]
#.NET Annoyances: Drawing a bitmap that doesn't take forever

As I've described before, the .NET framework provides lots of support for drawing lines and circles and polygons, but stinks the place up rather badly when you want plot a lot of pixels. Using the single-pixel bitmap technique, I found that plotting a not-unreasonable 150,000 pixels took over 5 seconds, which left me, having to draw six or eight such images, with a rendering time of up to 30 or 40 seconds. That's bad.

If you dig around a bit the stuff you need to draw bitmaps at good speed (ie, quickly enough that you don't bother getting the stopwatch out) is all there, it's just not really talked up anyway. The reason for that is that it's frightfully un-.NETty, flirting as it does with raw memory access, undocumented behaviour and all that kind of stuff.

First of all, you need a bitmap

  Bitmap bmp = new Bitmap(width, height);
which we then lock

  BitmapData bd = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);

The rectangle doesn't have to cover the whole bitmap, so you can just select part of it if you want to. The LockBits documentation threatens to throw an exception if the PixelFormat is wrong, without describing which values might be right. Format24bppRgb worked for me.

The BitmapData object, bd, now has information we need. Most crucial is bd.Stride. The width you specified in the call to LockBits may not be the width of the actual area locked, as it will have been aligned on a word boundary (possibly depending on the pixel format, I think). The value of bd.Stride is, therefore, not necessarily equal to width. Armed with the height and bd.Stride we can allocate a linear array of bytes onto which we will actually do our drawing.

  int bufferLength = bd.Stride * height;
  byte[] buffer = new byte[bufferLength];

The start of the buffer corresponds to origin (0,0), and you just map your points into it

  for(int x = 0; x < whatever; ++x)
    for(int y = 0; y < something; ++y)
    {
      Color colour = data[x][y];


or whereever your data comes from

      int index = (y * bd.Stride) + (x * 3);

We do x*3 here, because we specified 24bpp, so 3 bytes per pixel. Unfortunately we just have to know this, this value isn't available at runtime. Notice also that bd.Stride is given in bytes, not pixels.

      buffer[index] = colour.B;
      buffer[index+1] = colour.G;
      buffer[index+2] = colour.R;
    }


Note the order the colour bytes are set, blue is low, and that we need to use the Stride value to index into the buffer. Almost there now.

So, buffer is full of our data which we need to shove back into our bitmap

  System.Runtime.InteropServices.Marshal.Copy(buffer, 0, bd.Scan0, bufferLength);
  bitmap.UnlockBits(bd);


If you've made any mistakes, particularly in calculating the buffer size, you'll get a runtime exception from one or other of these calls.

That's it - the Bitmap can be drawn using DrawImage, DrawImageUnscaled or DrawImageUnscaledAndClipped.

Very little of this seems to be documented properly. I found out the byte order by trial and error, for example. If you try another pixel format, you'll have to do some similiar experimentation. To my mind, this looks like a lot of fiddly-faff and there are all kinds of questions I'd like to ask whoever designed this (like why do I need to lock the bitmap in memory but then allocate my own seperate buffer?), but it works and it's quick.

[More Annoyances]


[Add a comment]
#Disappointed

Nipped into the city centre yesterday to try and score a few comics. Arriving well before the advertised closing time, I nonetheless found the place locked up. My annoyance was compounded when I realised it was probably something to do with this stupid football malarkey.


[Add a comment]
Friday 23 June, 2006
#[linkfarm] Last night was Birmingham, and my performance was quite good.
[Add a comment]
#

Strolled out to the city centre with chums Pete and Tom, and Tom's chum Dan to refresh my Bob Mould man-crush. He played more or less the same set as at Bristol in January, but the gig had quite a different feel. The crowd was smaller but warmer which was good (also older, greyer and balder). The lighting was quite bright though, which meant that not only could we see Bob, he could see us. He closes his eyes a lot as he plays. When he opens them it's with this slightly crazed stare, and it's a little unnerving when his gaze falls on you. Worth it though. He'll be back with a band next year. I'll be there.


[Add a comment]
Thursday 22 June, 2006
#[linkfarm] Scaling Up with XQuery, Part 1 - Bob DuCharme shows us how to use three popular XQuery implementations to access and query large XML document collections, which is, as he says, "where the real fun begins."
Scaling Up with XQuery, Part 2
[Add a comment]
Tuesday 20 June, 2006
#Astoria XQuery Demo

There are probably only three people in the world even remotely interested in this, but here's the picture anyway.

OK, maybe interested is too strong a word. That's a little .NET form, written in C#, running XQuery over an Astoria database using Saxon.NET. Astoria documents are wrapped in System.Xml compatible classes, demand loading child nodes so you only load the bits you use. The fn:doc XQuery function understand eclipse URIs in addition to the normal file and http varieties. The fn:collectin XQuery function takes a cabinet name and hands back all the docs that cabinet contains. It's all taken a bit less than a day.

On the one hand I feel like a programming rockstar, but on the other, well, you know, a bit silly. Maybe if it impresses the right people, they'll pay me to finish it off.

smellygit said Can I play guess the customer now? [added 20th Jun 2006]
There isn't a customer yet. I'm pitching, more in hope than expectation :) [added 20th Jun 2006]
AngryJohn [e] said just don't let on that it'll take longer to run than to program when they use it on a cabinet of actual data. [added 21st Jun 2006]
Don't care so long as I get the work :) Acutally, it's looking reasonably speedy. I've got another XML database with built-in XQuery and they feel as quick as each other. I'll grant you that I haven't got an enormous dataset though. [added 21st Jun 2006]
Marc said Nice, i'm impressed anyway. [added 22nd Jun 2006]
Cool! Thanks, Marc. [added 23rd Jun 2006]
smellygit said Marc likes anything with pointy brackets in though ;) [added 26th Jun 2006]
I'll take all the pops I can get. [added 26th Jun 2006]
kal said "Whats Jez up to these days?" I thought.

Wish I hadn't now.

I'll go back to me tea. [added 30th Jun 2006]

People in glass houses shouldn't throw stones, sharepoint-boy. [added 30th Jun 2006]

[Add a comment]
Monday 19 June, 2006
#[linkfarm] Time to start referencing ISO standards? - Did you know there are ISO standards for the following: PDF, HTML and Dublin Core Metadata? I didn't.
[Add a comment]
#[linkfarm] Henry Rollins: A Love Letter To Ann Coulter
[Add a comment]
Wednesday 14 June, 2006
#[Arabica]XPath Evaluation bug
For the document
  <doc>
    <p>
      <ftr>footer 1</ftr>
    </p>
    <p>
      <ftr>footer 2</ftr>
    </p>
  </doc>
XPathExpectedArabica behaviour
//ftrSelect both ftr elementsCorrect
//ftr[1]Select both ftr elementsWrong - selects nothing
//ftr[2]Select nothingCorrect - but for the wrong reasons
XPath ExpressionExpectedArabica behaviour
(//ftr)[1]Select first ftr elementCorrect
(//ftr)[2]Select second ftr elementCorrect
Wrote a test case for this. The failing assertion is line 666. Dum-dum-*dum*! [added 23rd Jun 2006]
Fix committed to CVS. XPath/impl/xpath_step.hpp 1.26 [added 23rd Jun 2006]

[Add a comment]
Sunday 11 June, 2006
#[linkfarm] Definition of 'Planet' Expected in September - ... after seven years of debate. Blimey - I'd always assumed you'd know one when you saw one
[Add a comment]
#[linkfarm] As Wednesday morning dawned, northern Norway was hit with an impact comparable to the atomic bomb used on Hiroshima. - Meteorite!
[Add a comment]
#

Just finished reading a section of JPod in which one programmer, Kaitlin, lists the what she terms the microautisms of her cubicle-collegues. Came away wondering if I have some degree of auditory hyperacuity (don't really like the sounds of other people eating, often think people talk too loudly, have been known to wander the house at night trying to track down a buzzing noise that turned out to be the fridge or to turn off a dripping tap at far end of the house), face blindness (difficulty in reading people particularly strangers, but perhaps everyone has that), or whether I lack emotional reciprocity (often finish conversations aware that the other person has asked all the questions, misinterpret small talk pleasantries as genuine enquiries, that kind of thing). Probably I'm just a socially inept neurotypical acting like a hypochondriac with a medical encyclopedia.

This morning, I dropped the Bean off at his dance rehearsal. As I arrived back home, Hal saw me from the bedroom window and ran out on to the landing to shout hello down the stairs. "Hi Hal!" I replied, "what are you doing?" I was slightly startled when he replied "Standing at the top of the stairs."


[Add a comment]
Wednesday 07 June, 2006
#[linkfarm] Andrew read the Daily Express from Monday May 8th to Sunday May 14th, but he has since made a full recovery. - Watch as one man puts his sanity on the line ...
[Add a comment]
Tuesday 06 June, 2006
#

Chum Ken popped round today to pick up some extra 2000ADs I'd unearthed during the move. He brought his son Ben and some more early 80s vintage comics fanzines with him. He took Ben away again, but he left the mags. They really are top. From 1982, we have BEM 35 featuring an enormous Pat Mills interview, a terrific Nemesis and Torquemada cover by Kev O'Neill, a further feature on Nemesis with Mills scripts and O'Neill pencils and inks and six page sci-fi story written and pencilled by our Lord Eddie Campbell. Also from 82 is Lew Stringer's Fantasy Express 4 with more O'Neill and huge great interview with Joe Colquhoun. We just don't do fanzine's like this anymore. I should round up a few of today's thrusting young zine publishers, take the zines and smack them all around the head with them until they get the message. More seriously, I'm starting to think I should scan this stuff, or at least bits of it. They're comics folk history, and if we don't preserve it, it'll just get lost.


[Add a comment]
Monday 05 June, 2006
#

Am enjoying JPod very much. It's not huge in the way of plot, but it's snappy and cynical and the programmer jokes are almost all accurate. It's also written in very short chunks, so it's ideal for the multi-tasking IT professional. Although Natalie completely failed to notice, the novel immediately preceding JPod as my evening time reading was Miss Wyoming, also by Douglas Coupland. I read the opening couple of chapters several years ago the morning following my chum John's stag do, nursing a significant hangover, sitting on the lavvy at about 8:30 in the morning. When I eventually picked up a copy, I recalled them almost completely. Is that a recommendation?


[Add a comment]
Friday 02 June, 2006
#[linkfarm] A guy who owned a comic shop in Hull, England, really tried his best to get me into Grimjack a whole nine years before I actually got round to buying and reading an issue - The sole online reference that I could find to my one-time comics dealer, Jack.

   * jon [e] said Was it Armadillo (which changed to Springbank Comics, then vanished withou a trace)? The staff there were funny. Especially the ginger bloke. He was right tosser. "If you're not buying anything, don't come in!" Hahahahahahahah. Wonderful memories. [added 22nd Mar 2008]

No, it was Final Frontier, later Grimjacks, on Princes Avenue. [added 22nd Mar 2008]

   * alex [e] said hi im have in my possion two mint copys of 2000-ad issuse 4/5 still in pakaging never opened im havin truble finding the best place to sell. im looking for a collectors does anybody know were to find a collector? [added 27th Jul 2009]

[Add a comment]
<< May 2006 July 2006 >>