Thursday, January 21, 2010

Klok 2 Beta update fixes critical issue

If you have been using the Klok 2 beta, the previous update (Klok 2 Beta Build 2.01) had a serious issue that caused it to hang while launching in some cases. If you have experienced this problem, you can download the update manually using the email you received when you joined the beta program.

If you have not experienced this issue we strongly recommend that you install the update (and all updates during the beta) when prompted.

Also, make sure you keep up to date with progress by visiting the Klok Facebook page and submit any bugs at http://bugs.mcgraphix.com



Wednesday, January 13, 2010

New Klok 2 Beta build posted last night

Last night I posted a new build (1.17) of the Klok 2.0 beta which fixes some issues with snapping on the week view as well as an issue on the comments tab of the timesheets.

We are getting close to release. If you find critical issues make sure you submit them at http://bugs.mcgraphix.com so I can determine when we are ready for release.

Monday, January 11, 2010

Your donations are on their way

Your donations are on their way to help feed those struggling with hunger so I would like to take another moment to thank all the Klok 2 Beta Testers:

Stijn V. E., Brian V., Perisoft, Nick O., Andrea C., Ritual, Kaolin S., Benjamin W., Jan B, Sidney K., Sebastian Z., Adam W., David M., Justin J., Nicole N., Michael P., Jonal J., Thomas S., Zdenek M., Joel W., Ariane D., Karalyn P., Oscar S., Pawel P., Agrobio Products B.V., Brian C., mFace Marketing Solutions, Glenn H., Jay M, Daniel A., Benjamin T., Data Logg, Eric O., Adam G., Blaine E., John B., Alchmi, Helge H., Ross S., Rupert E., Brandon B., Farrell Documentation, Wouter V., Denis B., Stacy K., Ken Y., Phillip R, John S., Jonas N., Exit12, Jordan H., Anders T., Wouter G., Andy H., Hogan & Associates, Anna K., John S., Ofer G., Anthony M., Sean B., Frank J., James T., Charles R., Grade A, Taylor B., Steven J., Hung P., Michael Z., Torgny B., David B., Paul S., Rob H., Mitch F., Jon W., TRR Digital Industries, Liam D., , Shaun D., Blahnik Digital Designs, Don S., Larry M., Octave 2 Media, Stephen C., David P., Malcolm O., Chistian K., Jason D., mcgraphix, inc., , Trevor G., Mark A., Mark A., Betrand P., Steven W., Sofia P., Clifford L., Benjamin H., Ziad W., Steffen W.

Half of each of your donation is going to Feeding America. For more information on how you can help visit their website.

Friday, January 8, 2010

High resolution PDFs from Flex

I was recently working on a mechanism to save some panels (similar to some Dashboard graphics from the Klok 2 dashboard view) created in a Flex application to the user's harddrive by converting them to PDF. The obvious choice for PDF creation is AlivePDF. However, the quality of the resulting PDF was...well terrible. The problem was that instead of trying to recreate every last bit of my app in the PDF, I was just passing a reference to each panel into the pdf.addImage method like so:

pdf.addImage(myPanel)


What this actually does is take a low resolution screenshot (72 DPI) of the component and add it as an image to the pdf. So when you print the pdf, the quality is pretty bad. After some digging I found this post which seemed to be exactly what I was looking for. I thought that simply doing this would do the trick:

var image:ImageSnapshot = ImageSnapshot.captureImage(myPanel, 300, new PNGEncoder());

The problem is caused by the fact that Alive PDF doesn't support transparent PNGs which is what is returned when using the PNGEncoder class which is part of Flex.

A little more digging (several hours worth actually) turned up this post which again sounded like my solution. Applying the code fix from that got me almost there. I created my own NonTransparentPNGEncoder which was basically a copy of the built in PNGEncoder with this new version of internalEncode() method:
private function internalEncode(source:Object, width:int, height:int,
transparent:Boolean = false):ByteArray
{
// The source is either a BitmapData or a ByteArray.
var sourceBitmapData:BitmapData = source as BitmapData;
var sourceByteArray:ByteArray = source as ByteArray;
if (sourceByteArray)
sourceByteArray.position = 0;
// Create output byte array
var png:ByteArray = new ByteArray();
// Write PNG signature
png.writeUnsignedInt(0x89504E47);
png.writeUnsignedInt(0x0D0A1A0A);
// Build IHDR chunk
var IHDR:ByteArray = new ByteArray();
IHDR.writeInt(width);
IHDR.writeInt(height);
IHDR.writeByte(8); // bit depth per channel
IHDR.writeByte(2); // color type: RGBA
IHDR.writeByte(0); // compression method
IHDR.writeByte(0); // filter method
IHDR.writeByte(0); // interlace method
writeChunk(png, 0x49484452, IHDR);
// Build IDAT chunk
var IDAT:ByteArray = new ByteArray();
for (var y:int = 0; y <>
{
IDAT.writeByte(0); // no filter
var x:int;
var pixel:uint;
for (var j:int = 0; j <>
{
pixel = sourceBitmapData.getPixel(j, y);
IDAT.writeByte(pixel >> 16 & 0xFF);
IDAT.writeByte(pixel >> 8 & 0xFF);
IDAT.writeByte(pixel & 0xFF);
}
}
IDAT.compress();
writeChunk(png, 0x49444154, IDAT);
// Build IEND chunk
writeChunk(png, 0x49454E44, null);
// return PNG
png.position = 0;
return png;
}

One final change and I finally had it working:

pdf.addPage();
var image:ImageSnapshot = ImageSnapshot.captureImage(page, 300, new NonTransparentPNGEncoder());
var resize:Resize = new Resize ( Mode.FIT_TO_PAGE, Position.CENTERED );
pdf.addImageStream(image.data, ColorSpace.DEVICE_RGB, resize);



Then I just save my pdf to a ByteArray and use the FileReference to save it.

var bytes:ByteArray = pdf.save(Method.LOCAL);
var file:FileReference = new FileReference();
file.save(bytes, filename);

Keep in mind that although the panels are high resolution, they are still bitmap graphics. So, you will not be able to copy and paste any of your text out of the resulting PDF.

In order for all this to work, I am using 0.1.5 Beta version of AlivePDF, Flex 3.4 and Flash Player 10.

UPDATE: One last note. Because this is generating a 300DPI version of your component, it takes some time. A few seconds for a few page document.

Tuesday, January 5, 2010

Your New Year's Resolution that you can achieve... Make More Money

Now that 2009 is a distant memory and everyone is settled back into work now is good time to think about a New Year's resolution. I know, I hate them too. However, here's a resolution you can stick to with the help of Klok. Repeat after me... "I resolve to make more money by making sure I correctly keep track of my time and then bill for the time and effort I actual spend".

That's right... Track your time better. Actually bill for your time spent. Make more money. What could be better than that?

Also don't forget that if you track how long you spend on projects, you will be able to more acurately estimate the next one.