Tuesday, 24 May 2011

flex4, how to make an image brighter, i.e. for focus purposes, without modify it


situation

how to make easy(!) modifications in Image components with out modifying their data. The data modification (image modification) requires a lot cpu resources as result low performance.
problem

adobe flex4 AS3.0
how to make an image brighter, i.e. for focus purposes, without modify it

> page: dn
difficulty level

2/10 :)
compatibility

flex4, as3
solution

- drop a Label on the Image component to cover it, clear text property
- on this Label... set as background color the white color
- also set as blendmode the "overlay" value
- also set as backgroundAlpha the value 0.5
- now... on runtime play with "alpha" property of the Label with values 0..400




Tuesday, 17 May 2011

Oracle, virtualbox, how to import / insert a vdi file when the New and Add buttons are removed from the Virtual Media manager?


situation

Oracle, please, don’t be Microsoft! It is a shame to remove capabilities from this wonderful software!

The “new” and “add” buttons are removed from the Virtual Media manager from version 4.0.0 because simply they are idiot (I can’t find other logical reason). It is shame to reduce the capabilities of a too powerful application.
problem

Oracle, virtualbox, how to import / insert a vdi file when the New and Add buttons are removed from the Virtual Media manager?
difficulty level

2/10 :)
compatibility

virtual box >= 4.0.0
solution

To add a vdi info your "Virtual Media Manager" do the follow:
- Go at the "Settings" of any virtual machine. If you haven’t any, create a dummy (there is no need to create disk for it).
- Go at the "Storage" section.
- Click of the “ide controller” (or “sata controller”)
- On the same line of the "controller" the two “add” buttons will be appeared, click on “Add hard disk”
- Then click on “choose existing disk”
- Select the vdi file and will be inserted to Virtual Media Manager.
- From this point, you may use this disk in any Virtual machine you want.
attention

The problem occurred in version 4.0.0 - 4.0.6 at least.

Sunday, 15 May 2011

visual studio - c# / vb - Label is not transparent

Problem
Setting the Backcolor of the Label component to web -> Transparent, the Label is not transparent at all!

Solution
This is because MS is confused about what is really transparent! Forget the transparent effect between the components!
This Transparent color means that if you set Backgroundimage at the container where hosts the Label component, the Label will be transparent at the image that is loaded in the container.
In practice...
- create a Form
- set a Backgroundimage at the created form, load a jpg file...
- drop a Label compoent
- set the at Label component the property Backcolor to web -> Transparent

Now  you have a transparent Label in the way of Microsoft :(

Tuesday, 10 May 2011

Visual Studio - error: System.Security.SecurityException was unhandled (trying to use a referenced DLL)


situation

Visual Studio compiles an application that is using a foreign DLL (a referenced one) but on run time whern the app tries to use the dll occurs the follow error
problem

Visual Studio - error
System.Security.SecurityException was unhandled
  Message="That assembly does not allow partially trusted callers."
difficulty level

1/10 :)
compatibility

VS2008
solution

project -> properties -> security -> check Enable ClickOnce Security Settings -> select This is a full trust application

Monday, 9 May 2011

Firebird sql; How to make the Firebird SQL server portable, supporting the network connections!!!


situation

Firebird SQL server project, supports to be portable, as your application will use the same DLLs as the Firebird SQL server does; by this way you may open FDB files from your application without install the Firebird Server. The main disadvantage is that you can’t open the same FDB file from other application and of course there is no network support to open the FDB as remote database from other terminal(s).
By the way, if you are interesting how you do this, search at the internet and at Firebird's official page. I’ll go further as I will show to you how to make the Firebird server portable as it is, with network support also!
problem

Firebird
How to make the Firebird SQL server portable, supporting the network connections!!!
difficulty level

9/10 :(
compatibility

fb 2.0, 2.1 & 2.5
solution

Sunday, 8 May 2011

Flex: how to make a image cache? (easier way) - REFdn4007673813


situation

how to make a image cache?
problem

adobe flex4 AS3.0 the image component
how to load images save them to cache…
and how apply them to Image components
---
> page by dn
difficulty level

9/10 :(
solution

In order to make a cashe of the photos/images, I do the follow simple way:
- With URLLoader I download the data… the "Complete" event gives me the "data" property… in this property the data of the image is in binary format (don't be afraid). I save this "data" to another variable (or array) of Object type. For this example, I named this variable "downloadData" you will see bellow.
- In order to load the data on a visual component Image, I do the follow code:
myImage.data=downloadData;
attention

no attentions!

How to Cache Images in Your Flex Application - REFdn5077575832

Caching images in your Flex application can greatly improve performance and reduce the overhead of loading external resources.
And I’m not simply talking about using the cacheAsBitmap property to improve rendering performance or the cachePolicy property to speed up animations. I’m talking about caching the actual bitmap data of an image.
To get started, you’ll need a hash map to store the image data. A Dictionary or an associative array will also work just fine.
Loading an image for the first time is the same as usual. You create a new Image object and add a listener for the COMPLETE event:
var image : Image = new Image ();
image.addEventListener (Event.COMPLETE, onImageComplete);

Once the image has finished loading, you add a copy of the bitmap data to the hash map using the image URL as the hash key:
private function onImageComplete (event : Event) : void
{
    var image : Image = event.target as Image;

    if (! imageCache.containsKey (image.source))
    {
        var bitmapData : BitmapData = new BitmapData
            (image.content.width, image.content.height, true);

        bitmapData.draw (image.content);

        imageCache.put (image.source, bitmapData);
    }
}

Now we can use the image as many times as we want without ever having to load it again!
To take advantage of this, you’ll need to check the hash map every time you create a new image (or change the source property) to see if you’ve already cached it:
var image : Image = new Image ();
image.addEventListener (Event.COMPLETE, onImageComplete);

if (imageCache.containsKey (imageURL))
{
    image.source = new Bitmap (imageCache.getValue (imageURL));
}
else
{
    image.source = imageURL;
}

And that’s it!
If you have an application that loads a large number of images you may want to limit the number of cached images to prevent the Flash player memory usage from getting out of hand, but in general caching even several dozen large images only results in a slightly increased footprint.