AutoHotkey Community

It is currently May 24th, 2012, 7:19 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 108 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 8  Next
Author Message
 Post subject:
PostPosted: October 29th, 2006, 9:54 am 
Offline

Joined: October 27th, 2006, 6:35 am
Posts: 14
This is exactly what I've been looking for but I got an error.

"Error in GdipCreateBitmapFromFile (2: InvalidParameter) 0 (At GDIplus_LoadBitmap)"

:?:


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

Joined: January 18th, 2006, 7:39 am
Posts: 274
Location: Conway, Arkansas
If you're running the test script as it is, you will need to create a bitmap file in the same directory as the script named: OriginalImage.bmp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2007, 10:25 am 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
Well, PhiLho, I finally got around to testing the functions in your GDIplusWrapper.ahk, and they work as advertised. Great stuff!

Can I assume that the set of GDI+ functions you've wrapped (and their allowed parameters) don't depend on any particular version of GDIplus.dll?

On my test system, WinXP SP2, the version loaded by default when I tested was 5.1.x and was one of two versions stored in the Side-by-Side assembly store, %SystemRoot%\WinSxS\..., the more recent one and presumably the default. Several other versions, however, exist in various application folders, including a couple of Adobe apps (they were older) and, most notably, a version 6.0.x in the Office 2003 folder, though none are in the system %PATH%. I'm just trying to gauge the extent to which an AHK app that uses GDI+ via your functions will be compatible across a wide range of machine (on some of which other SxS versions may have been installed by different apps, maybe even made the default). If versions are a problem, I think a properly formatted .config file can be placed in the same folder to specify a desired version, or Resource Hacker could be used to supplement the config file already stored as a resource in AutoHotkeySC.bin (it currently just specifies version 6.x of comctl32).

Jacques.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2007, 12:34 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
JBensimon wrote:
Can I assume that the set of GDI+ functions you've wrapped (and their allowed parameters) don't depend on any particular version of GDIplus.dll?
Frankly, I don't know, but I will answer yes. I didn't saw version-specific info in the API found in MSDN.

_________________
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: February 6th, 2007, 10:50 pm 
Skan wrote:
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, :)


Skan, can GDImage.DLL be incorporated into AHK script?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2007, 5:45 pm 
Offline

Joined: December 14th, 2005, 3:08 pm
Posts: 219
I'm looking for a way to record the current displayed desktop background in Windows 2000/XP.

Change it for my own image.

Then put the original image back.

Now I know I can record the current user registry settings

Code:
RegRead, Original_TileWallpaper, HKEY_CURRENT_USER, Control Panel\Desktop, TileWallpaper
RegRead, Original_WallpaperStyle, HKEY_CURRENT_USER, Control Panel\Desktop, WallpaperStyle


and alter them.

But how do force Windows to re-read these new registry settings and refresh the background?


Would the ahk GDI library be able to do this?

_________________
Stuart Halliday


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2007, 6:18 pm 
quatermass wrote:
Would the ahk GDI library be able to do this?
No, this is totally unrelated.
Search the forum in this section, you will find scripts to change the background.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2007, 11:48 pm 
Offline

Joined: March 1st, 2007, 7:37 pm
Posts: 14
Thanks for your really great work. I'm using it to capture parts of a window and save it as picture.
However, I would like to rotate and/or flipp the Image. I found something promissing in your warper script that might do the job:

; For a JPEG image, specifies lossless 90-degree clockwise rotation.
#EncoderValueTransformRotate90 = 13
; For a JPEG image, specifies lossless 180-degree rotation.
#EncoderValueTransformRotate180 = 14
; For a JPEG image, specifies lossless 270-degree clockwise rotation.
#EncoderValueTransformRotate270 = 15
; For a JPEG image, specifies a lossless horizontal flip.
#EncoderValueTransformFlipHorizontal = 16
; For a JPEG image, specifies a lossless vertical flip.
#EncoderValueTransformFlipVertical = 17

Unfortunatelly I'm too stuipid to figure out how to use those Encoder Values.
Could you provide a small sample script on how to use them? That would help a lot.

Thanks in advance.

-John


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 2nd, 2007, 11:06 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
I am sorry, but I have not explored GDI+ image transformations yet, and don't plan to do it soon, due to lack of time and other projects. If somebody else is willing to do this, (s)he is welcome.

_________________
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: March 2nd, 2007, 12:36 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I have a script doing the transformation, but unfortunately not in AHK. I only sketched the needed procedure here, so, you have to adjust it appropriately.

BTW, it just re-used the returned structure by the system. It may not be a good idea, however.

Code:
DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize)
VarSetCapacity(pi, nSize)
DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", &pi)

nValue := 14 ; JPEG Transformation: 13 14 15 16 17

EncodeInteger(&pi +  0, 1)                     ; number of list
; 4 - 20                                     ; 16 byte CLSID of Encoder
EncodeInteger(&pi + 20, 1)                     ; number of values
;EncodeInteger(&pi + 24, 4)                     ; type of values
EncodeInteger(&pi + 28, DecodeInteger(&pi + 28) + 4 * (nValue - 13))      ; address of the value

pParam := &pi

DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", &wFileTo, "Uint", pCodec, "Uint", pParam)


DecodeInteger(ptr)
{
   Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
}

EncodeInteger(ref, val)
{
   DllCall("ntdll\RtlFillMemoryUlong", "Uint", ref, "Uint", 4, "Uint", val)
}



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2007, 6:39 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Here are GUIDs I found so far which are used in GdiPlus.

Code:
ImageFormatUndefined := "{B96B3CA9-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatMemoryBMP := "{B96B3CAA-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatBMP       := "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatEMF       := "{B96B3CAC-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatWMF       := "{B96B3CAD-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatJPEG      := "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatPNG       := "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatGIF       := "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatTIFF      := "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatEXIF      := "{B96B3CB2-0728-11D3-9D7B-0000F81EF32E}"
ImageFormatIcon      := "{B96B3CB5-0728-11D3-9D7B-0000F81EF32E}"

ImageCodecBMP        := "{557CF400-1A04-11D3-9A73-0000F81EF32E}"
ImageCodecJPEG       := "{557CF401-1A04-11D3-9A73-0000F81EF32E}"
ImageCodecGIF        := "{557CF402-1A04-11D3-9A73-0000F81EF32E}"
ImageCodecEMF        := "{557CF403-1A04-11D3-9A73-0000F81EF32E}"
ImageCodecWMF        := "{557CF404-1A04-11D3-9A73-0000F81EF32E}"
ImageCodecTIFF       := "{557CF405-1A04-11D3-9A73-0000F81EF32E}"
ImageCodecPNG        := "{557CF406-1A04-11D3-9A73-0000F81EF32E}"
ImageCodecIcon       := "{557CF407-1A04-11D3-9A73-0000F81EF32E}"

EncoderTransformation   := "{8D0EB2D1-A58E-4EA8-AA14-108074B7B6F9}"
EncoderQuality          := "{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"
EncoderLuminanceTable   := "{EDB33BCE-0266-4A77-B904-27216099E717}"
EncoderChrominanceTable := "{F2E455DC-09B3-4316-8260-676ADA32481C}"
EncoderCompression      := "{E09D739D-CCD4-44EE-8EBA-3FBF8BE4FC58}"
EncoderColorDepth       := "{66087055-AD66-4C7C-9A18-38A2310B8337}"
EncoderSaveFlag         := "{292266FC-AC40-47BF-8CFC-A85B89A655DE}"
EncoderVersion          := "{24D18C76-814A-41A4-BF53-1C219CCCF797}"
EncoderScanMethod       := "{3A4E2661-3109-4E56-8536-42C156E7DCFA}"
EncoderRenderMethod     := "{6D42C53A-229A-4825-8BB7-5C99E2B9A8B8}"



Last edited by Sean on March 3rd, 2007, 9:12 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2007, 9:05 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
OK, I converted the script to AHK. It'll work only with JPEG files. Adopting it to TIFF should be easy. Other formats produced no available parameter list in my test. And, it incorporates only two parameter types, Transformation and Quality, although there exist two more for JPEG, LuminanceTable and ChrominanceTable.

It requires CoHelper.ahk which can be saved here:
http://www.autohotkey.com/forum/topic16631.html

Code:
#NoEnv
#Include CoHelper.ahk

sFileFr := "C:\ImageFr.jpg"   ; Adjust the name
sFileTo := "C:\ImageTo.jpg"   ; Adjust the name

SplitPath, sFileFr, , , sExtFr
SplitPath, sFileTo, , , sExtTo

If (sExtFr <> "JPG") || (sExtTo <> "JPG")
{
   MsgBox % "Both Files must be of JPG! Now Exit the App."
   ExitApp
}

hModule := DllCall("LoadLibrary", "str", "gdiplus.dll")

VarSetCapacity(si, 16, 0)
si := Chr(1)

DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "Uint", &si, "Uint", 0)

DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
VarSetCapacity(ci, nSize)
DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "Uint", &ci)

Loop, %nCount%
{
   pTypes := DecodeInteger(&ci + 76 * (A_Index - 1) + 44)
   Unicode2Ansi(pTypes, sTypes)
   If InStr(sTypes, "." . sExtTo)
   {
      pCodec := &ci + 76 * (A_Index - 1)
      Break
   }
}

If !pCodec
   ExitApp

Ansi2Unicode(sFileFr, wFileFr)
Ansi2Unicode(sFileTo, wFileTo)

DllCall("gdiplus\GdipLoadImageFromFile", "str", wFileFr, "UintP", pImage)

DllCall("gdiplus\GdipGetEncoderParameterListSize", "Uint", pImage, "Uint", pCodec, "UintP", nSize)
VarSetCapacity(pi, nSize)
DllCall("gdiplus\GdipGetEncoderParameterList", "Uint", pImage, "Uint", pCodec, "Uint", nSize, "Uint", &pi)

nValue := 14                        ; JPEG Transformation: 13 14 15 16 17
EncodeInteger(&pi +  0, 1)                  ; number of list
;4 - 20                           ; 16 byte CLSID of Encoder
EncodeInteger(&pi + 20, 1)                  ; number of values
EncodeInteger(&pi + 24, 4)                  ; type of values
EncodeInteger(DecodeInteger(&pi + 28), nValue)            ; address of the value
pParam := &pi

/*
nValue := 90                        ; JPEG Quality: 0 - 100
EncodeInteger(&pi + 28, 1)                  ; number of list
;32 - 48                        ; 16 byte CLSID of Encoder
EncodeInteger(&pi + 48, 1)                  ; number of values
EncodeInteger(&pi + 52, 4)                  ; type of values
EncodeInteger(DecodeInteger(&pi + 56), nValue)            ; address of the value
pParam := &pi + 28
*/

DllCall("gdiplus\GdipSaveImageToFile", "Uint", pImage, "Uint", &wFileTo, "Uint", pCodec, "Uint", pParam)

DllCall("gdiplus\GdipDisposeImage", "Uint", pImage)
DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
DllCall("FreeLibrary", "Uint", hModule)



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2007, 11:28 pm 
Offline

Joined: March 1st, 2007, 7:37 pm
Posts: 14
Sean wrote:
OK, I converted the script to AHK. It'll work only with JPEG files.

Thanks a lot!
But how do I enable the JPEG Quality settings? If I activate the part that is commented out in your script, the rotation is no longer working.
What I'm doing wrong?

-John


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2007, 12:46 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
JohnCritton wrote:
But how do I enable the JPEG Quality settings? If I activate the part that is commented out in your script, the rotation is no longer working.

I think you have to apply them separately, because of the difference of their nature.
I reckoned it would work to combine them as the adjacent blocks and set the number of list to 2. But, it didn't work. It may be because Transformation is a lossless operation (:so, only work from JPEG to JPEG) whereas Quality is a lossy operation (:so, works from ANY FORMAT to JPEG).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2007, 8:03 pm 
Offline

Joined: June 3rd, 2007, 5:49 am
Posts: 36
Surprised nobody really brought this up yet given that digtal cameras are abundant now and store exif information which states the orientation.

I just need to display the jpg file in it's correct orientation resized to fit a window.

So it needs to
Load jpg
Get w,h,exif orientation
rotate if necessary
calculate w if h is sized to windowheight
calculate h if w is sized to windowwidth
determine show mode (fit or crop)
show appropriate dimension based on mode

Any idea how best to implement this?? I think this is useful enough to be implemented into the ahk library when done

_________________
http://willyfoo.com
http://livestudios.com


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, 6 ... 8  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: tic and 9 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