AutoHotkey Community

It is currently May 27th, 2012, 7:50 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 108 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next
Author Message
 Post subject:
PostPosted: September 15th, 2006, 4:04 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
I updated the library to have a new function: GDIplus_CaptureScreenRectangle
Requested in Screenshot of a little part of the screen, thanks for idea, and thanks holomind for the starting point.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2006, 1:00 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Very nice. There have definitely been requests for capturing only a portion of the screen.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2006, 8:59 am 
Offline

Joined: August 8th, 2006, 3:55 pm
Posts: 49
I am very interested to have the possibilty to capture only a portion of the screen and was eagerly waiting for it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2006, 6:03 pm 
Hello, PhiLho.
Very usefull image functions!Thanks for your work.
May I suggest the inclusion of the "GdipDisposeImage(GpImage *image)" function to release the image so we can use|delete|overwrite it?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2006, 8:58 pm 
Offline

Joined: June 4th, 2005, 1:30 am
Posts: 113
Location: Stuttgart, Germany
Splendid! Thanks PhiLho, holomind!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2006, 10:48 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Paulo [not logged] wrote:
May I suggest the inclusion of the "GdipDisposeImage(GpImage *image)" function to release the image so we can use|delete|overwrite it?
Good idea! I neglected the functions to free memory, partly because I don't know well the API (whose flat API is badly documented), partly because these functions were made mostly for a one-shot use, but people will start to use them in permanently running scripts, so freeing memory will be necessary.
I will add this soon. Do you see other places in my functions where I should manage / free the memory?

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on October 2nd, 2006, 9:53 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2006, 5:07 pm 
PhiLho wrote:
...Do you see other places in my functions where I should manage / free the memory?

Your functions seem perfect, I just mentioned "GdipDisposeImage" because (as you wrote) I am using your wrapper in a "non-one-shot" script.
Thanks,again.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2006, 12:14 pm 
Offline

Joined: November 3rd, 2004, 11:24 am
Posts: 51
How to resample/resize PNG picture with alpha-transparency using this technology? And may be convert ICO to PNG?

_________________
My AHK project: http://landvermesser.tripod.com/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2006, 12:51 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Good questions, I think GDI+ can do that, but it needs some research... I won't do that right now.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2006, 1:24 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear PhiLho, :)

This might interest you ( in case you have not already visited )
http://www.zapsolution.com/winlift/gdimage.htm
GDImage.DLL (Windows 32 bit) is commerical, I downloaded and tried some .exe examples provided.

The examples were absolutely breath taking .. :shock:
The CHM help provided is excellent!

I guess the DLL (60KB) is a kind of wrapper built around GDI & GDIPLUS.
I installed it and have uploaded the contents as a .ZIP for you:
The ZIP : http://autohotkey.net/~goyyah/samples/GDImage.zip
Or take a glance at the documentation:
The CHM : http://autohotkey.net/~goyyah/samples/gdimage.chm

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2006, 5:10 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear PhiLho, :)

I am taking a dive into GDIplusWrapper.ahk today ..

.. and I think it would help newbies if you could post seperate and simple
examples for every feature instead of one long TestGDIPlus.ahk

Just a suggestion.. Thanks for writing the wonderful code.

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2006, 9:08 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Well, the TestGDIplus.ahk isn't so big, and I separated the various features with comments and/or labels...
It could be cleaner, but that's more a quick test code than a tutorial that I don't have much time to do.
But I welcome any contribution... ;-)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 16th, 2006, 9:43 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
PhiLho wrote:
But I welcome any contribution... ;-)


Sure .. :D

I will try to make simple examples for posting in ask-for-help.
I wanted to demonstrate ( Carlol topic Timer on MsgBox? ) displaying
clipboard image data on a GUI.

Right now I am writing the image to disk and then displaying it.
Is there a way to directly display hBitmap ( or whatever! ) as a picture control?

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2006, 11:12 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
No need for GDI+ here.
That's the opportunity to test the famous STM_SETIMAGE as pointed out by Chris in http://www.autohotkey.com/forum/viewtopic.php?t=10091
As you can see, I reused your own GUI... :-)
Code:
appTitle = Show Graphic Clipboard
STM_SETIMAGE = 0x0172
IMAGE_BITMAP = 0
GMEM_MOVEABLE = 2
guiWidth  = 400
guiHeight = 300
titleBarHeight = 24
clientHeight := guiHeight - titleBarHeight

Gui -Caption +Border
Gui Add, Picture,  x0 y%titleBarHeight% vimage gChangeImage, KM64.png
Gui Font, s9 Bold, Tahoma
Gui Margin, 0, 0
Gui Add, Text,  x0 y0 w%GuiWidth% h%titleBarHeight% +0x4   ; SS_BLACKRECT
Gui Add, Text,  x0 y0 w%GuiWidth% h%titleBarHeight% cFFFFFF Backgroundtrans +0x200 gGuiMove
      , %A_Space%%A_Space%%appTitle%   ; SS_CENTERIMAGE?
Gui Show, w%guiWidth% h%guiHeight%, %appTitle%
Gui +LastFound
Return

GuiMove:
   PostMessage 0xA1, 2, , , A   ; WM_NCLBUTTONDOWN
Return

ChangeImage:
   If (DllCall("IsClipboardFormatAvailable", "UInt", 2) = 0)
   {
      MsgBox 16, %appTitle%, No Bitmap Available
      Return
   }
   r := DllCall("OpenClipboard", "UInt", 0)
   If (r = 0)
   {
      MsgBox 16, %appTitle%, OpenClipboard
      Return
   }
   hBitmap := DllCall("GetClipboardData"
         , "UInt", 2)   ; CF_BITMAP = 2, CF_DIB = 8
   If (r = 0)
   {
      MsgBox 16, %appTitle%, GetClipboardData
      Goto ClipboardCleanUp
   }
   If (hBitmap = 0)
   {
      MsgBox 16, %appTitle%, No Bitmap
      Goto ClipboardCleanUp
   }
   ; Make a copy of this data, because the handle points to data that will disappear on CloseClipboard
   r := DllCall("CopyImage"
         , "UInt", hBitmap
         , "UInt", IMAGE_BITMAP
         , "Int", 0, "Int", 0   ; Keep same dimensions
         , "UInt", 0)   ; No special flag
   If (r = 0)
   {
      MsgBox 16, %appTitle%, CopyImage
      Goto ClipboardCleanUp
   }
   hBitmap := r
   ReplacePictureImage("Static1", hBitmap)

ClipboardCleanUp:
   DllCall("CloseClipboard")
Return

GuiEscape:
ExitApp

; Given a Picture control (_pictureTitle),
; and a bitmap handle (from clipboard, from GDI operations, etc.),
; tell the Picture to change its image.
; Better than BitBlt, because we don't have to manage WM_PAINT...
; Note that the given _hBitmap no longer belongs to the caller,
; either the Picture owns it, or it is destroyed, for consistent behavior.
ReplacePictureImage(_pictureTitle, _hBitmap)
{
   local hOldBitmap, hCurrentBitmap

   ; From info taken from http://www.autohotkey.com/forum/viewtopic.php?t=10091
   ; and from the source (in script_gui.cpp).
   ; Reset the image of the control before deleting it
   SendMessage STM_SETIMAGE, IMAGE_BITMAP, 0, %_pictureTitle%
   ; Handle on the previous bitmamp
   hOldBitmap := ErrorLevel
   If (hOldBitmap != "FAIL" and hOldBitmap > 0)
      ; Destroy it
      DllCall("DeleteObject", "UInt", hOldBitmap)
   ; Set new image
   SendMessage STM_SETIMAGE, IMAGE_BITMAP, _hBitmap, %_pictureTitle%
   ; Get the handle on the bitmap stored by the control
   SendMessage STM_GETIMAGE, IMAGE_BITMAP, 0, %_pictureTitle%
   hCurrentBitmap := ErrorLevel
   ; If it is different than the sent one, XP made a copy because image has alpha transparency
   If (hCurrentBitmap != "FAIL" and hCurrentBitmap != _hBitmap)
      ; So delete the sent image, to avoid a memory leak
      DllCall("DeleteObject", "UInt", _hBitmap)
}
I had a hard time to find how to copy the data in the bitmap from the clipboard. Most examples I saw on the Net merely copy Microsoft examples, BitBlting it to the screen... I started to use a convoluted method, when I found that CopyImage existed...
Using GDI is basically quite simple, it worked in my first attempt where I just use STM_SETIMAGE with the hBitmap directly taken from the clipboard, but it would have seriously leaked memory and GDI resources... Correctly releasing created data is the difficult part of this API.
I encapsulated the core functionnality in a function, for easy reuse.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on October 29th, 2006, 5:48 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2006, 6:29 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Wow! :shock: .. :D
I have to take a deep look .. Will try it & post again!

Many Thanks :D

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 108 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Cristi®, nothing and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group