Pulkit Gaur

dream - do - deserve

Ultra fast Screen Capture

Filed under: Visual Basic at 13:09:40 On 2006-06-29

This is one of the fastest and smallest method to capture screen.

I am putting this in visual basic to make easily understandable to newbees.

 

Visual basic timer object reports time 0 seconds for this operation !


Here goes the code.


'API Declarations

Private Declare Function CreateDCAsNull Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, lpDeviceName As Any, lpOutput As Any, lpInitData As Any) As Long

Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long


'Sub To be called
'For example Use : dumpScreenToPicturebox(picture1)

Public Sub dumpScreenToPicturebox(targetPictureBox As Control)

lngDesktopDC = CreateDCAsNull("DISPLAY", ByVal 0&, ByVal 0&, ByVal 0&)
BitBlt targetPictureBox.hdc, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, lngDesktopDC, 0, 0, vbSrcCopy

End Sub




Hope it was useful !Cool

StretchBlt API limitations

Filed under: General at 08:23:36 On 2006-06-24

While working on a company project came thru this weird limitation of Stretchblt API.

Actually i was working on some huge images of the order of 3500 * 2500 pixels with 24 bit depth.My display card settings were 1280 * 1024 32 bit ( yes,it matters ! ) on winXP.

Now, when ever i try to zoom the complete bitmap with a scaling factor of greater than 1.2 StretchBlt returns false.

Seems,i exceed the selectors limit for StretchBlt.


PS: I found ,StretchBlt is quite slower while working with huge bitmaps or downsampling them.

PLOG passed XHTML 1.0 validation

Filed under: General at 07:41:00 On 2006-06-19

Well,


It took about 2 hours to fixup all the invalid markup's in PLOG.
Now its a valid XHTML translation. 

For the proof ,click the link on the right to verify. Cool

 

AJAX web album with instant zooming

Filed under: Javascript at 12:19:53 On 2006-06-15

Well,

Had nothing much to do on tuesday so did this small AJAX based web album with zooming and background loading.

Its not using any backend rightnow ,everything is coded in just one page.
But it provides instant zooming with background fetching.So gives a nice interface where you need not wait for images to get downloaded.
That part goes in background.


I assume many web albums like Flickr and Picasa web album are using the same trick.

Though,it can be made even better by using GD library as backend.
But you see, i am a bit busy cool


Anywayz you can visit it here.

Will keep on working this !

Visual Basic ByRef gotcha

Filed under: Visual Basic at 11:57:45 On 2006-06-14

A few dayz back my friend raghav was working on one ActiveX for company project.

He got stuck at one point where his procedure was changing the value of a variable while using ByRef.( The project is done in Visual Basic)

I also tried to figure out the problem but in vain frown.

BTW i never use ByRef in ActiveX control's coz i prefer to use classes most of the time.

Later ,searching this on net i found that whenever you enclose the passed variable in parenthesis Visual basic evaluates this as an expression and your passed variable becomes a ByVal passed variable.

So,

//Code Begin

foo(myInt)

..............................

...............................

Private Sub foo(myVar)

myVar = newValue

End Sub

//Code End

Will not change the value of myInt to newValue.

Rather :

//Code Begin

foo myInt

..............................

...............................

Private Sub foo(myVar)

myVar = newValue

End Sub

//Code End

Will do the Trick

Strange but true cool

PS: Anywayz Microsoft has made ByVal as a default method to pass variables in dotNET.

Google search - results relevance Irony !

Filed under: General at 01:00:37 On 2006-06-11

They say that they provide most appropriate search results to the user.

A few days back while searching a term "robotics" i was amazed to find US robotics - a telecom euipment company to be listed first.

How will google justify this ?

irony

While the same search term on Yahoo gave me a relevant search result.

works fine

Javascript global variables

Filed under: Javascript at 23:43:14 On 2006-06-08

Discovered something which i should have figured out earlier.

window.myvariable = some_value;

is same as a global variable declared like

 

................

................

var some_value;

function foo(){

............

}

 

Strange but true wink

 

Top 10 Supercomputers

Filed under: General at 03:05:04 On 2006-06-03

top 10 list

* Taken from top500.org

Cookie limits on your browser

Filed under: General at 11:00:21 On 2006-06-03

Tried to find out some session info about cookies.

This info i found,Your browser supports:

    * 300 cookies in total
    * 20 cookies per domain
    * 4096 bytes per cookie

It seems as though this minimum requirement is part of the original RFC for cookies - see section 6.3 specifically