Saturday, February 10, 2007

WPF: loading images, audio, video

hmmm. strange that loading images more ma2 fan2 than loading video/audio
must set width/height. tried without and no image : (

loading images:
Image LoadImage(String imageFileName)
{
// Create source
BitmapImage myBitmapImage = new BitmapImage();

// BitmapImage.UriSource must be in a BeginInit/EndInit block
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri("pack://siteoforigin:,,,/" + imageFileName);

// To save significant application memory, set the DecodePixelWidth or
// DecodePixelHeight of the BitmapImage value of the image source to the desired
// height or width of the rendered image. If you don't do this, the application will
// cache the image as though it were rendered as its normal size rather then just
// the size that is displayed.
// Note: In order to preserve aspect ratio, set DecodePixelWidth
// or DecodePixelHeight but not both.
myBitmapImage.EndInit();
Image i = new Image();
i.Source = myBitmapImage;
i.Width = myBitmapImage.Width;
i.Height = myBitmapImage.Height;
return i;
}

loading audio/video:
xaml:
<MediaElement Grid.Row="2" Name="myMedia" LoadedBehavior="Manual"/>

cs:
myMedia.Source = new Uri("mymediafile.wmv", UriKind.Relative);
myMedia.Play();

Friday, February 09, 2007

What am i busy with?

Hmm...

switch(task){
case 1:
prepareFor1stBorn(); //-- baby coming
break;
case 2:
doASsignments(); //-- NTU modules
break;
case 3:
doResearch(); //-- NTU dissertation
break;
case 4:
mark(); //-- mark exam papers
break;
}

How to teach programming???

am waiting for wifey at her office. still cracking my brain how to teach oopm more effectively... :(

//-- status now
boolean isFrustrated = true;
while(isFrustrated){
thinkSomeMoreIdeas();
}

Thursday, February 01, 2007

AS3: SoundMixer.computeSpectrum()

public static function computeSpectrum(outputArray:ByteArray, FFTMode:Boolean = false, stretchFactor:int = 0):void

Takes a snapshot of the current sound wave and places it into the specified ByteArray object. The values are formatted as normalized floating-point values, in the range -1.0 to 1.0. The ByteArray object passed to the outputArray parameter is overwritten with the new values. The size of the ByteArray object created is fixed to 512 floating-point values, where the first 256 values represent the left channel, and the second 256 values represent the right channel.

Flash: BitmapData.draw

Draws a source image or movie clip onto a destination image, using the Flash Player vector renderer

draw(source:Object, [matrix:Matrix], [colorTransform:ColorTransform], [blendMode:Object], [clipRect:Rectangle], [smooth:Boolean])