Thursday, February 26, 2004

WellFormed released

February's Well Formed is available.

The mail shot has gone out but I have had a lot of bounce notifications this month. Maybe people have their spam systems turned up high.

If you haven't got your copy yet, ping me and let me know.

Thursday, February 05, 2004

Revised article

I updated the article which explains how to capture a control. RelaseDC needed a window handle and an hDC. The old code only had the hDC so a memory leak was caused.

Friday, January 30, 2004

Not polite?

I've just noticed that a few comments have been posted through the HaloScan system which I seem to have had no notification for. Normally when somebody posts a comment I get a mail telling me that it's there but for the last few days and certainly the last few comments made I have had nothing. This may be to do with the recent spate of e-mail viruses and the fact that I've got my Spam checking turned up to its fullest extent so please, if you make a comment and I don't respond straight away, be patient.

Sunday, January 25, 2004

Wednesday, January 14, 2004

Monday, January 12, 2004

ColorMatrix weirdness

Someone asked me a simple question on Saturday that has had me wracking my brains and pulling out my hair over the weekend. They had a problem with an image containing some text which they had tried to invert to a negative but which came out completely black even though the original text was black on a white background. Obviously, it was expected to show white text on a black background. First of all I thought this was a bug and searched around in the code for errors but could find nothing glaringly obvious. Then I sat down and wrote a simple test that loaded up a picture, drew a checkerboard pattern of black squares on top of the picture and made a negative image using the color matrix as described in my GDI+ FAQ article. Imagine my surprise when the negative image had black squares on it instead of cyan ones. I was even more surprised when every graphic I tried came out black in the negative instead of its inverse color. I tried black, white, red, blue, green, yellow and magenta text and graphics and everything came out black in the negative image.

Suddenly, I realized that the common factor with all of these colors is that they all had one or more elements fully saturated or zero with no intermediate values whatsoever. The answer is of course that when using the color matrix to create a negative image color triplet values are multiplied by -1. These values are also eight bit values and so 255 multiplied by -1 is -255 which overflows the 8 bit value to zero. This means that every color with a fully saturated component will be incorrect in the negative and therefore inverting a negative created with this process will produce an incorrect positive.

In an effort to overcome this problem I decided that the solution was to ensure that there were no elements in the image which had fully saturated values or zeros in any of the pixels. To do this I used the color matrix again this time scaling all the colors to make them a tiny bit darker and then shifting all the colors up by one value. This produces positive images which are imperceptibly changed and which produce perfect negatives every time. I am just in the process of updating the GDI+ FAQ with this information and a little bit of code.

Saturday, December 20, 2003

Speed of light

The odometer of my car just went over the one light-second mark this morning. :-)

Wednesday, December 17, 2003

What's it all about?

First of all, a little bit of history. Since the mid 1980's I've been very active on newsgroups and forums run by CompuServe and Microsoft. In fact, since I became a self employed consultant. I give out a lot of information freely and I've always made an effort to explain the principles behind my answers rather than just paste a link to somebody else's answer or tell somebody where to look in the help file. Furthermore, I maintain a web site with comprehensive articles, extensive code in both C# and visual basic which is used as a resource by literally thousands of engineers all over the world.

I discovered many years ago that helping people out for free can be advantageous because people often contact me afterwards and offer me contracts, both short and long term, and even fulltime employment in their companies. As a consequence, I am able to make a living through the Internet and those forums and newsgroups which I frequent are often the primary point of contact between me and my clients.

Whenever I post in a newsgroup my signature carries links to my website, articles and products. This has always been the case. Furthermore, I often post announcements to my products and services which are clearly marked as such and are easily filtered by those people who do not wish to see such announcements by the simple expedient of a filter that removes the subjects tagged with a ANN: prefix.

Recently, I was given the MVP award by Microsoft, largely for my work on the newsgroups but significantly, for the content of my website and my advocacy of Microsoft products. This is to say that my practices are certainly not incompatible with the Intent of the Microsoft public newsgroups. Indeed, I am somewhat surprised because having been recently singled out by members of a newsgroup because of "unacceptable practices" I looked back through the newsgroup archives to discover that there are numerous announcements for commercial products from other MVPs and companies which have drawn no comment whatsoever.

One thing I will not do is to be drawn into a public flame argument on a newsgroup. I have a comment section on this blog and anyone is free to put whatever they like on there.

Monday, December 15, 2003

MSDN style documentation

I've been an advocate of inline documentation for source code for many years. In a previous incarnation as Director Of Engineering at stingray, I hassled my poor teams relentlessly for good source documentation. I was very pleased indeed when I saw that C# provided built in XML documentation and quite liked code comment reports generated by the visual studio IDE.

For the last week or so, I have been involved in heavily documenting a project that has taken me almost a year to complete for a client in the UK. Although I had already used the bill in XML documentation for the C# based classes and have generated the code, and report pages on several occasions I found them lacking and to be honest, I think my client did too. After revisiting all the documentation and beginning to document several of the visual basic classes and examples in my project using the VBCommenter from the GotDotNet site. I discovered the absolutely superb nDoc project on the SourceForge site.

nDoc enables you to produce MSDN style documentation in the form of .CHM files and web sites that look absolutely fantastic and integrate with the standard MSDN help files for such information as inherited members and so on.

Someone asked me the other day if I would put help files on the site for xray-tools so as an experiment, and because I've had to make a change to the tool recently, I have read on the documentation for the RectTracker control and put it up on my site.

Wednesday, December 10, 2003

New article posted in GDI+ FAQ

I've just posted an article on the GDI+ FAQ on the subject of colour saturation in images and how to adjust it using the ColorMatrix class.

Tuesday, November 25, 2003

Yahoo domains.. big problems.

I just discovered something odd concerning Yahoo Domains.

A bug in their billing software has cause many customers to not be charged for services for some considerable time despite the fact that service continued. Even though the error was theirs, when they discovered the problem, they suspended thousands of accounts that were past-due (according to their billing system) without any notice, cutting off businesses and individuals from their sites, causing loss of revenue for many of them and only restoring service after they had resolved the problems internallly. There are apparently still thousands of accounts suspended and they are working to clear the backlog.

I think that an error on their part should be met with good grace and the accounts in question remain in-service until customers could be contacted and the internal problems fixed. After-all. The problem was not the fault of the individuals who suffered.

They post this message on the main login page, Note there is no mention of the fact that the fault was all theirs...

"November 21 2003 . Reactivation of Suspended Accounts
Important note for accounts which are suspended due to past due payment: It will take 24-36 hours to reactivate your account once you provide valid payment information. Until your account is reactivated, your domain name and associated services will not function. "

Thursday, November 20, 2003

Productivity shifts in visual studio.net 2003.

For many years visual basic programmers were able to crow about the fact that productivity was so much better using visual basic and using C++. Now however, C# programmers have the upper hand because visual studio provides enhancements for them that are not available to the VB programmer. For example, implementing an interface for a C# programmer is as easy as pressing the tab key. Visual basic programmer's however still have to select the interface in a drop down and then the method in another drop down which can become tedious if you have a whole lot of interfaces to implement. The same is true for event handlers.

Problems sorted. Get on with life.

The web-site is back up. I must remember to change hosting provider. I need a site with ASP+ hosting and Yahoo domains don't cut the mustard.

Wednesday, November 19, 2003

The world has gone nuts!!!

Now my web-site isn't working.

I can be contacted on bobpowell1@yahoo.com

Tuesday, November 18, 2003

Relief.....

I got home from the cybercafe where I was trying to do my mail and run my life with a bunch of teenage kids playing quake and making a fuss and the networks back up again.

Four days without internet is like an eternity or three.

Disaster strikes

My son recently moved to another apartment and so I phoned up for him to cancel his phone account. Instead of cancelling his, the idiots at France Telecom cancelled mine because it was the one from which the call originated. I have to re-order my ISDN connection and wait for it to be set up again. You can imagine how happy i am about that!!!!

Tuesday, November 11, 2003

String manipulation of a different kind...

I saw a link to the US PBS network Nova site the other day and was enthralled by the 3 hour program on string theory. If science grips you, check it out!.


Back to blog

I've been deep in documentation, help files and installs for my consulting clients this week and all other spare time has been taken up with a marathon article on text formatting for Well Formed which I'm just finishing up for this month.

Wednesday, November 05, 2003

Bugs that were reported over a year ago still apparent in Whidbey

I've seen somebody complaining on one of the newsgroups today that a bug that was reported over year ago is still apparent in the PDC release of longhorn. I have just verified myself that there is another bug which I reported over a year ago that has not yet been fixed in the GDI+ Whidbey code. Both bugs are extremely simple defects and in the case of the one which I reported I even told them what line of code to add to fix it and yet it still malfunctions.

The two bugs in question are problem with clip rectangles that don't clip to the correct pixel and a serious memory leak in Region.GetScanRects.

The second of these errors is a serious showstopper because it means to say that you cannot use a GDI+ region to clip a directx surface because there's no way of extracting the region rectangles to hand off to the directX clipper.

New Graphics classes for Whidbey.

The new GDI+ classes in the Whidbey alpha include classes called BufferedGraphics ans BufferedGraphicsContext.

A BufferedGraphicsContext enables you to allocate a rectangular graphics buffer, encapsulated by the BufferedGraphics class, which you can draw on using standard Graphics methods and then render at any time with a Render() method.

The following snippet shows how a buffer is allocated and drawn into. It can then be rendered at any time. In this instance I rendered it before and after painting on the graphics in the normal way.

The buffered graphics are always maintained in the allocated area.

private void Form1_Paint(object sender, PaintEventArgs e)
{
BufferedGraphicsContext c=new BufferedGraphicsContext();
BufferedGraphics bg = c.Allocate(e.Graphics,new Rectangle(10,10,200,200));

bg.Graphics.FillEllipse(Brushes.Red,0,0,300,300);

bg.Render(e.Graphics);

e.Graphics.FillEllipse(Brushes.Pink, 30, 30, 400, 20);

bg.Render(e.Graphics);
}