Dan's Tech Den For the Cyber Warrior

3Nov/120

Embed Images as binaryData in AS3 to reduce SWF size

This evolved from a lengthy discussion on the file size of an SWF.

It seems that Flash/Flex embeds PNGs as 32bit only. And this in some cases causes the size of the image to be greatly increased. In some cases the size of the image more than doubles if the image had been compressed using optimization utilities.

The solution to keep the reduced size that I came up with is to embed the image as binaryData instead of a bitmap using the mimeType='application/octet-stream' like this

[Embed(source = "assets/8bit.png", mimeType = "application/octet-stream")]
public static const IMG:Class;

But this gives us a ByteArray instead of the needed bitmap.

This ByteArray can be decoded into a bitmap using the Loader.loadBytes() function, but this function is asynchronous and thus this step needs to be performed in advance, during initial game loading.

For this I have made the following OctetStreamBitmapDecoder class

19Jan/101

Syllabus of 8th Semester CSE

I have scanned and uploaded the syllabus for 8th Semester CSE at Chandigarh College of Engineering and Technology.

You can download the syllabus from here:

CSE 8th Semester Syllabus

19Nov/0917

Using CppUnit with Visual Studio

It is a unit testing framework ( a port of JUnit ) for C++ .
The benifit of having a unit testing procedure is that , you can use it either in Test Driven Development or as a standalone test (for testing when needed).
With CPPunit, its very easy to write and run unit tests, as well as integrate the runs with the build process.

Installing CppUnit

The first thing is, there is no installation. The distribution is the source code which must be compiled with the compiler you are using for your C++ work.

Setting up CPPUnit (on windows using Visual Studio):

  1. Download latest release of CPPUnit
  2. Extract the zip contents.
  3. Open the Visual Studio 6 workspace file in the examples directory of the extracted folder.
  4. If you are using Visual Studio 2005 or 2008, it wont compile out of the box.

Fix For Visual studio 2005 and 2008

Open file MsDevCallerListCtrl.cpp in the folder srcmsvc6testrunner.
Find the following line

#import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids

and change the version("7.0") to:
version("8.0") for VS 2005
version("9.0") for VS 2008

Now do a batch build for all configurations.
Dont worry about errors yet.
Go and look into the lib directory in the cppunit directory.
if you have cppunit.lib, cppunit_dll.lib and cppunit_dll.dll, then you are ready to go.