AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Save Screen (HDC) as BMP or PNG w/o external tools, GDIPlus
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Oct 10, 2006 9:58 am    Post subject: Reply with quote

Note I added GDIplus_FreeImage to my wrapper, it might be what is needed...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
AHKsimple



Joined: 27 Oct 2006
Posts: 14

PostPosted: Sun Oct 29, 2006 9:53 pm    Post subject: Reply with quote

How do you use this to capture images spontaneously (frames for screen video)? I tried combining the copy with the save w/ one hotkey and looped it but it doesn't work. I can hold the hotkey but it's pretty slow so the quality isn't so good....
Back to top
View user's profile Send private message
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Sun Oct 29, 2006 10:15 pm    Post subject: Reply with quote

@ahksimple: I think You will not be able to record the video as it is rendered as hardware overlay or Direct Draw, which is not visible in the Desktop HDc until you change Video acceleration to "Software" in Windows Media Player, "Performance" . Capturing Video to Hard drive is too slow with This ahk-script, you might use FRAPS for this
http://www.fraps.com/
i don't think this will work good enough with AHK or GDl in this case
Back to top
View user's profile Send private message Visit poster's website
JSLover



Joined: 20 Dec 2004
Posts: 542
Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...

PostPosted: Sun Oct 29, 2006 10:19 pm    Post subject: Reply with quote

holomind wrote:
...you might use FRAPS for this...

...screw fraps...not free...& adds that annoying overlay on videos (never used it, but I've seen other peoples vids with that damn fraps overlay)...try...
  • Taksi (Sourceforge)
      site blurb: Taksi is a utility that allows you to take screenshots and record video clips of your favorite games and other 3D-graphics applications. Inspired by Fraps (www.fraps.com), Taksi aims to provide an open source alternative to that great tool.

      sf blurb: Taksi is a video capture/screen capture tool for 3D graphics applications (such as games). It can capture almost any windows application using DirectX, OpenGL, or GDI and create an AVI file using any installed VFW codec or still frames in PNG.
...I found this after all my other suggestions in the other post...I never said AHK would be fast enough to do it...just use CamStudio or Taksi...
_________________

Home • Click image! • Blog
Back to top
View user's profile Send private message Visit poster's website
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Sun Oct 29, 2006 11:08 pm    Post subject: Reply with quote

@jslover : You will never get 100 fps with GDI you will need DirectX/Draw or opengl to get enough Speed unless you want 2fps?!

Fraps perhaps does not really much ,it simply copies the Gfxfrontbuffer to a file.similar to this.If you cant afford $37
http://www.codeproject.com/audio/avigenerator.asp
Back to top
View user's profile Send private message Visit poster's website
AHKsimple



Joined: 27 Oct 2006
Posts: 14

PostPosted: Mon Oct 30, 2006 5:24 am    Post subject: Reply with quote

Okay. I used to have FRAPS and it was free....I dunno but all the ones I've tried have some numbers in the corner or does some funky stuff with the mouse cursor. I use CursorXP to use different cursors but anyway, I'm sorry if this is getting off topic but quickly, does anyone know any video editing software with an interface that allows you to layer videos, music, captions, etc., add pics and manipulate them in other ways (separate the video file into segments, adjust time length of titles/captions/pics, basic effects/transitions, etc.)? Sort of like Windows Movie Maker interface with the duration and everything, only as a Movie editor instead... The main features I'm looking for are being able to seperate the video files and music into segments, cutting video/music short, and basically anything to edit/arrange (deleting parts out, taking sample clips from the files, changing the order, etc.) that I can save into a standard video file format (avi, mpg, wmv....).
Back to top
View user's profile Send private message
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Mon Oct 30, 2006 11:44 am    Post subject: Reply with quote

the ones i know are "adobe Premiere" and "final cut", or "aftereffects" but they are not cheap
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Oct 30, 2006 12:17 pm    Post subject: Reply with quote

I saw good reviews (in French) of Pinnacle Studio Plus 10.0 (100€), Ulead VideoStudio 9 (80€), Magix Video Deluxe 2006 Plus (100€), Canopus Let’s Edit 2 (150€).
They are not cheap indeed... But I doubt a freeware would do this job.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
AHKsimple



Joined: 27 Oct 2006
Posts: 14

PostPosted: Tue Oct 31, 2006 2:22 am    Post subject: Reply with quote

Thanks. I'm going to try and make something that takes screenshots of specific actions when they happen, naming the screenshot files according to the action and takes the screenshot name info to show a log in a msgbox when I press a hotkey. Boy, that's going to take a lot of work (btw, I'm completely new to scripting if it wasn't obvious enough already). I've got a ton of studying to do. lol. Is there any other resources besides the quick start tut and the help guide? I can't find much on the format of scripts used for parameters and such(all those brackets and tabbing...and spaces).
Back to top
View user's profile Send private message
NiJo



Joined: 12 Nov 2005
Posts: 73

PostPosted: Thu Nov 02, 2006 3:39 am    Post subject: Reply with quote

@Holomind:
Great Utility Very Happy but...
I upgraded your script to use the latest GDIplusWrapper.ahk from Philho, modded some things and inserted a HotKey to take PrintScreen of the ActiveWindow (Just like Alt+PrintScreen). Yes, it uses the Wrapper now instead of your Helper, sorry Sad
The script got a lot easier to understand, thanks to Philho Wink.
Script: ScreenShooter
Back to top
View user's profile Send private message
holomind



Joined: 11 Mar 2006
Posts: 300
Location: Munich, Germany

PostPosted: Thu Nov 02, 2006 4:24 pm    Post subject: Reply with quote

@niho: for me the script looks very similar, but you added some for screenshot of region etc. the gdiwrapper is from philho and i only "use" it. there is much room to improve the script, its more a proof of concept, that you can make screenshots only with builtin tools like gdi or gdiplus. i am glad is somebody improves the script. in longterm using gdi (or graphics in general) with ahk will/should be improved. i also have some wrapper functions in the expose-clone script. because i dont like the dllcall-syntax and thus use wrappers.
Back to top
View user's profile Send private message Visit poster's website
sma



Joined: 06 Dec 2006
Posts: 1

PostPosted: Wed Dec 06, 2006 7:56 am    Post subject: holomind Reply with quote

The code is function and the speed is ok.
Is it possible to add the curser pointer to the captured picture ?
Back to top
View user's profile Send private message
Murp|e



Joined: 12 Jan 2007
Posts: 246
Location: Norway

PostPosted: Sat Feb 17, 2007 3:19 am    Post subject: SitaShot Reply with quote

holomind and PhiLho,

Thanks! I've been wanting to make this little program for a year or so and this made it so much more tempting to start coding. I've been using QuickShot for some time which has the same functionality as this. I found QuickShot to be a little slow and I like the idea of hosting the screenshots on my own server. This takes a full screenshot of the screen and uploads it to your own FTP server. It's meant to be dead-simple and fast. I use it mostly in IM chats when the other person can't receive files. (I've only added the code-snippet between "#Z::" and "return", assides from that it's identical to holomind's script.)

Code:
#Include GDIPlusHelper.ahk
;SitaShot by Murp|e. Updated 2007-02-17.
;Takes a screenshot of your desktop and automatically uploads it to your web server.
;You need to customize this with the information from your server. Search this code for the string "your" and customize all the values. Take a screenshot with Win+Z.
;See: http://www.autohotkey.com/forum/viewtopic.php?t=11860 for orignal
;Credits to holomind and PhiLho for the excellent code!!


Menu, Tray, icon, SitaShot_Icon.ico

OnExit, handle_exit

main:
  FileCreateDir, screens
  FileCreateDir, thumbs

  WinGet, hw_frame, id, "Program Manager"   ; Desktop ?
  hdc_frame := DllCall( "GetDC", "uint",  hw_frame )
  hdc_frame_full := DllCall( "GetDC", "uint",  hw_frame )
  counter:=0   ; thumbnails
  counter_f:=0   ; fullscreens
  thumb_w:= 200
  thumb_h:= ceil( thumb_w * A_ScreenHeight / A_ScreenWidth ) ; keep screenratio
  use_antialize := 1
 

  ; buffer
  hdc_buffer := DllCall( "gdi32.dll\CreateCompatibleDC"     , "uint", hdc_frame )
  hbm_buffer := DllCall( "gdi32.dll\CreateCompatibleBitmap" , "uint", hdc_frame, "int", thumb_w, "int", thumb_h )
  r          := DllCall( "gdi32.dll\SelectObject"           , "uint", hdc_buffer, "uint", hbm_buffer )

  hdc_buffer_full := DllCall( "gdi32.dll\CreateCompatibleDC"     , "uint", hdc_frame_full )
  hbm_buffer_full := DllCall( "gdi32.dll\CreateCompatibleBitmap" , "uint", hdc_frame_full, "int", A_ScreenWidth, "int", A_ScreenHeight )
  r_full          := DllCall( "gdi32.dll\SelectObject"           , "uint", hdc_buffer_full, "uint", hbm_buffer_full )

  ; comment this line for speed but less quality
  if use_antialize = 1
    DllCall( "gdi32.dll\SetStretchBltMode", "uint", hdc_buffer, "int", 4 )  ; Halftone better quality with stretch

return

#Z::
Gosub, SaveImage_Full

FileDelete, Secret_FTP_Commands.txt
FileAppend,            ;Creates a temporary file with the FTP commands, could this be avoided?
(
yourdomain.com         ;The username you use to log on to your FTP.
yOurpassWOrd           ;The password you use to log on to your FTP.
cd /yoursub/folders     ;Choose a subfolder on your web domain such as /screenshots
lcd \screens
bin
prompt n
put "%fileNameDestP%"  ;Uploads the file.
quit
), Secret_FTP_Commands.txt

runwait, ftp -s:Secret_FTP_Commands.txt ftp.yourdomain.com
FileDelete, Secret_FTP_Commands.txt

clipboard = http://www.yourdomain/yoursub/folders/%SitaShotFilename% ; Change this line too. Same values as above.
msgbox, Screenshot successfully uploaded and link copied to clipboard! ;It doesn't know if anything actually succeeded, it's just very optimistic about it all.
return


#v::
SaveImage_Full:
  counter_f := counter_f +1
  FormatTime, myTime, , yyyyMMdd_hhmmss
  fileNameDestP = screens\S_%myTime%_%counter_f%_%A_ScreenWidth%x%A_ScreenHeight%.png
  StringTrimLeft, SitaShotFilename, fileNameDestP, 8


  If (GDIplus_Start() != 0)
     Goto GDIplusError

  ; Copy BMP from DC
  DllCall( "gdi32.dll\BitBlt"
          , "uint", hdc_buffer_full, "int", 0, "int", 0, "int", A_ScreenWidth, "int", A_ScreenHeight
          , "uint", hdc_frame_full,  "int", 0, "int", 0, "uint", 0x00CC0020 )

  DllCall( "GDIplus\GdipCreateBitmapFromHBITMAP", uint, hbm_buffer_full, uint, 0, uintp, bitmap )

  ; Save to PNG

  If (GDIplus_GetEncoderCLSID(pngEncoder, #GDIplus_mimeType_png) != 0)
     Goto GDIplusError

  noParams = NONE
  If (GDIplus_SaveImage(bitmap, fileNameDestP, pngEncoder, noParams) != 0)
     Goto GDIplusError
Return

GDIplusError:
   If (#GDIplus_lastError != "")
      MsgBox 16, GDIplus Test, Error in %#GDIplus_lastError%
   GDIplus_Stop()
Return

#c::
SaveImage:
  counter := counter +1
  FormatTime, myTime, , yyyyMMdd_hhmmss
  fileNameDestP = thumbs\T_%myTime%_%counter%_%thumb_w%x%thumb_h%.png
  If (GDIplus_Start() != 0)
     Goto GDIplusError

  ; Copy BMP from DC
  DllCall( "gdi32.dll\StretchBlt"
          , "uint", hdc_buffer, "int", 0, "int", 0, "int", thumb_w, "int", thumb_h
          , "uint", hdc_frame,  "int", 0, "int", 0, "int", A_ScreenWidth, "int", A_ScreenHeight, "uint", 0x00CC0020 )

  DllCall( "GDIplus\GdipCreateBitmapFromHBITMAP", uint, hbm_buffer, uint, 0, uintp, bitmap )

  ; Save to PNG

  If (GDIplus_GetEncoderCLSID(pngEncoder, #GDIplus_mimeType_png) != 0)
     Goto GDIplusError

  noParams = NONE
  If (GDIplus_SaveImage(bitmap, fileNameDestP, pngEncoder, noParams) != 0)
     Goto GDIplusError
Return


#x::
handle_exit:
   DllCall( "gdi32.dll\DeleteObject", "uint", hbm_buffer )
   DllCall( "gdi32.dll\DeleteDC"    , "uint", hdc_frame )
   DllCall( "gdi32.dll\DeleteDC"    , "uint", hdc_buffer )
ExitApp


I spent some hours making this today and there are several things I'd like to improve and would appreciate some pointers with.

1. I'd like to have one single file, instead of having two .AHK files. What is the easiest way of incorporating GDIPlusHelper.ahk into the main .AHK script?

2. The FTP part is fairly ugly since it exposes your FTP username and password for all to see. I don't personally care much about that, but I would imagine many people do. Does anyone know of an easy way to improve security?
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1388

PostPosted: Sat Feb 17, 2007 9:21 am    Post subject: Re: holomind Reply with quote

sma wrote:
Is it possible to add the curser pointer to the captured picture ?

You can do it using GetCursorInfo & GetIconInfo (:needed to obtain hotspot) APIs.

And, I think I also saw this question somewhere: can capture transparent windows too using BitBlt with CAPTUREBLT (:0x40000000) ROP.
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat Feb 17, 2007 9:23 am    Post subject: Re: SitaShot Reply with quote

Murp|e wrote:
1. I'd like to have one single file, instead of having two .AHK files. What is the easiest way of incorporating GDIPlusHelper.ahk into the main .AHK script?
Look at Image conversions with GDI+, I summarize here the needed functions.

Quote:
2. The FTP part is fairly ugly since it exposes your FTP username and password for all to see. I don't personally care much about that, but I would imagine many people do. Does anyone know of an easy way to improve security?
Laszlo provided encryption functions (TEA and RC4) which you can use to cancel this info from casual viewers. Of course, somebody knowing AutoHotkey can easily change the script to MsgBox the decrypted values: info must be decrypted before being sent to the FTP program! Smile
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group