Processing BitmapData.getPixels() With PHP

Have you ever worked with BitmapData.getPixels() method? This method generates a byte array from a rectangular region of pixel data. Writes an unsigned integer (a 32-bit unmultiplied pixel value) for each pixel into the byte array. Thats sounds good, but what is it good for to have a ByteArray full of integers? There is not even a decoder for this format on my backend?!… Well, this format is so cool, and easy to access that you do are able to write your own decoder e.g. in PHP.

The resulting bytes are 32-bit unsigned integers for each pixel represented by AARRGGBB format, followed by another pixels and so on e.g.:

AA RR GG BB:
-- -- -- --
FF FF 00 00
00 00 FF 00

Read the rest of this entry »

Numeric Sequence In SQL

Few years ago I came accross an issue, when I needed to find smallest continuous integer in a sequence. My data were like 1, 2, 3, 100, 101, 102, 520, 521, 530 and the task to find lets say next continuous bigger than 100. Long story short, fastest and the final SQL was:

SELECT t1.num+1 FROM table AS t1 
WHERE NOT EXISTS 
   (SELECT t2.num FROM table AS t2  WHERE t1.num+1 = t2.num) 
   AND t1.num>=100
GROUP BY t1.num ORDER BY t1.num LIMIT 1

Today, the issue was a little more difficult. I have to find smallest continuous 2D sequence in any direction.

Read the rest of this entry »

Image Caching With PHP

While working on my next project, I am looking for the best possible techniques to make it fastest possible (both client and server). My app requests a lot of images here and there, it may count up to hundreds or thousands requests in a while. I can not hold all of those wthin flash player cache because some of them may change, and I also want shortest possible respond times and client-server traffic reduction as well as server side computing reduction. Thats where browser caching comes into the scene. I have experimented a bit with all possible http headers to understand each browser specifics and I came with a solution.

Read the rest of this entry »

Facebook now with OAuth and Open Graph (update)

Few days before while I was working on TwitterLogger Class for ActionScript 3 I discovered OAuth – an open protocol to allow secure API authorization . While reading all the stuff about OAuth and PHP SDKs, I noticed one statement somewhere (can’t find it nowhere) that Facebook was in fact using OAuth for its Facebook Connect tool but some derived version. This has now changed! Facebook is standardizing communication and authorization by introducing Open Graph and OAtuh 2.0.

Read the rest of this entry »

P2P Multicast in Flash Player 10!

P2PMulticast communication flow

P2PMulticast communication flow

P2P multicast in Flash Player 10, yeap… ready? This method creates n:n model of p2p communicators. So broadcasting data goes from broadcaster directly to all receivers. All users are broadcasters and receivers. There is no multilevel logic in it, so keep in mind the upload bandwidth of broadcaster. Feel free to use it in your flash applications, just hit me when you decide.

Core classes and files:

Read the rest of this entry »