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 

per-pixel alpha blended GUI demo
Goto page Previous  1, 2, 3 ... , 11, 12, 13  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Thu Mar 20, 2008 7:27 am    Post subject: Reply with quote

I suspect the cursor is hidden for a very brief moment when you copy from the screen. I've noticed on older computers with integrated graphics, even PrintScreen will cause the cursor to disappear for a moment.
Quote:
Also, of the methods we discussed before, which do you think would be best for not showing the actual magnifier gui even on vista with aero?
Windows XP's magnifier simply shows the magnifier window as an empty dark grey window. Easy and effective...
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Fri Mar 21, 2008 2:12 am    Post subject: Reply with quote

I going to write it so that it fills the area where the mag is in the created bitmap with black. I am retreiving the cursor info, and have dual monitors (2nd monitor to the left of primary monitor) and when i move the mouse onto the left monitor with this script running, then the pos of the curosr, x is massive:

Code:
Loop
{
   VarSetCapacity(mi, 20, 0)
   mi := Chr(20)
   DllCall("GetCursorInfo", "UInt", &mi)
   hCursor := NumGet(mi, 8), xCursor := NumGet(mi, 12), yCursor := NumGet(mi, 16)

   VarSetCapacity(ni, 20, 0)
   DllCall("GetIconInfo", "UInt", hCursor, "UInt", &ni)
   xHotspot := NumGet(ni, 4), yHotspot := NumGet(ni, 8)
   x := xCursor-xHotSpot, y := yCursor-yHotSpot
   
   Tooltip, %x%`n%y%
   
   Sleep, 30
}

Esc::ExitApp


Do I need to & it with something?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Fri Mar 21, 2008 4:31 am    Post subject: Reply with quote

NumGet defaults to "uint". Specify "int".
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Mon Mar 24, 2008 6:18 am    Post subject: Reply with quote

Cool that worked.

This is more than a little bit of help, but this is really doing my head in:

Code:
#SingleInstance, Force
#NoEnv
DetectHiddenWindows, On
CoordMode, Mouse, Screen
SetBatchLines, -1
SetWinDelay, 0
SetWorkingDir %A_ScriptDir%

FitToWidth := 1
Zoom := 3
If FitToWidth
{
   SysGet, Monitor, MonitorPrimary
   SysGet, Mon, Monitor, %Monitor%
   MagWidth := MonRight-MonLeft
   MagHeight := (MonBottom-MonTop)//4
}
Else
MagWidth := 400, MagHeight := 400

Gui, 1: -Caption +LastFound +Resize +AlwaysOnTop +ToolWindow
hwnd1 := WinExist()
Gui, 1: Show, % FitToWidth ? "NA w" MagWidth " h" MagHeight " x" MonLeft " y" MonTop : "NA w" MagWidth " h" MagHeight          ;%
;WinSet, ExStyle, +0x00000020, ahk_id %hwnd1%
;WinSet, Transparent, 254, ahk_id %hwnd1%

hsc := DllCall("GetDC", "UInt", 0)
hdc := DllCall("GetDC", "UInt",  hwnd1)

bdc := DllCall("CreateCompatibleDC", "UInt", 0)
hbm := CreateDIBSection(bdc, MagWidth//Zoom, MagHeight//Zoom)
obm := DllCall("SelectObject", "UInt", bdc, "UInt", hbm)

hBrush := DllCall("CreateSolidBrush", "Int", 0x000000)
VarSetCapacity(RC, 16)

OnMessage(0x201, "WM_LBUTTONDOWN")

Loop
{   
   NumPut(0, RC, 0), NumPut(0, RC, 4), NumPut(MagWidth, RC, 8), NumPut(MagHeight, RC, 12)
   DllCall("FillRect", "UInt", bdc, "UInt", &RC, "UInt", hBrush)
   
   VarSetCapacity(mi, 20, 0)
   mi := Chr(20)
   DllCall("GetCursorInfo", "UInt", &mi)
   hCursor := NumGet(mi, 8), xCursor := NumGet(mi, 12, "Int"), yCursor := NumGet(mi, 16, "Int")

   VarSetCapacity(ni, 20, 0)
   DllCall("GetIconInfo", "UInt", hCursor, "UInt", &ni)
   xHotspot := NumGet(ni, 4, "Int"), yHotspot := NumGet(ni, 8, "Int")
   
   x := xCursor-xHotSpot, y := yCursor-yHotSpot
   Zoomx := x-(MagWidth//(2*Zoom)), Zoomy := y-(MagHeight//(2*Zoom))
   
   BitBlt(bdc, 0, 0, MagWidth//Zoom, MagHeight//Zoom, hsc, Zoomx, Zoomy)   
   WinGetPos, posx, posy, posw, posh, ahk_id %hwnd1%

   ; If (y-(MagHeight//(2*Zoom)) < posy+posh) && (y+(MagHeight//(2*Zoom)) > posy)
   ; {
      ; If (posy+posh-(y-(MagHeight//(2*Zoom))) >= posy+(y+(MagHeight//(2*Zoom))))
      ; {
         ; NumPut(0, RC, 0), NumPut(2*(MagHeight//(2*Zoom)) - (posy+(y+(MagHeight//(2*Zoom))))//(2*Zoom), RC, 4)
         ; NumPut(MagWidth, RC, 8), NumPut(100, RC, 12)
         ; DllCall("FillRect", "UInt", bdc, "UInt", &RC, "UInt", hBrush)
      ; }
   ; }   

   DllCall("DrawIcon", "UInt", bdc, "Int", MagWidth//(2*Zoom), "Int", MagHeight//(2*Zoom), "UInt", hCursor)
   
   StretchBlt(hdc, 0, 0, MagWidth, MagHeight, bdc, 0, 0, (MagWidth//Zoom), (MagHeight//Zoom))
   
   WinSet, AlwaysOnTop, On, ahk_id %hwnd1%
   Sleep, 30
}
Return

;###############################################################################################

GuiSize:
Gui, 1: +OwnDialogs
WinGetPos,,, MagWidth, MagHeight, ahk_id %hwnd1%

DllCall("gdi32\DeleteObject", "UInt", hbm)
DllCall("gdi32\DeleteDC", "UInt", bdc)

bdc := DllCall("CreateCompatibleDC", "UInt", 0)
hbm := CreateDIBSection(bdc, MagWidth//Zoom, MagHeight//Zoom)
obm := DllCall("SelectObject", "UInt", bdc, "UInt", hbm)
Return

;###############################################################################################

CheckSnap:
If GetKeyState("LButton", "P")
Return
SetTimer, CheckSnap, Off
MouseGetPos, Snapx, Snapy
Loop
{
   SysGet, Mon, Monitor, %A_Index%
   Monitor := A_Index
   If (Snapx >= MonLeft) && (Snapx <= MonRight) && (Snapy >= MonTop) && (Snapy <= MonBottom)
   Break
}
SysGet, WA, MonitorWorkArea, %Monitor%
WAWidth := WARight-WALeft
WAHeight := WABottom-WATop

If FitToWidth
{
   If (Snapy <= WATop+(WAHeight//2))
   WinMove, ahk_id %hwnd1%,, % WALeft, % WATop, %WAWidth%
   Else
   WinMove, ahk_id %hwnd1%,, % WALeft, % WABottom-MagHeight, %WAWidth%
}
Else
{
   If (Snapx <= WALeft+(WAWidth//2)) && (Snapy <= WATop+(WAHeight//2))
   WinMove, ahk_id %hwnd1%,, % WALeft, % WATop
   Else If (Snapx >= WALeft+(WAWidth//2)) && (Snapy <= WATop+(WAHeight//2))
   WinMove, ahk_id %hwnd1%,, % WARight-MagWidth, % WATop
   Else If (Snapx >= WALeft+(WAWidth//2)) && (Snapy >= WATop+(WAHeight//2))
   WinMove, ahk_id %hwnd1%,, % WARight-MagWidth, % WABottom-MagHeight
   Else If (Snapx <= WALeft+(WAWidth//2)) && (Snapy >= WATop+(WAHeight//2))
   WinMove, ahk_id %hwnd1%,, % WALeft, % WABottom-MagHeight
}
Return

;###############################################################################################

WM_LBUTTONDOWN()
{
   If (A_Gui = 1)
   {
      PostMessage, 0xA1, 2
      SetTimer, CheckSnap, 50
   }
}

CreateDIBSection(hDC, nW, nH, bpp=32, ByRef pBits ="")
{
   NumPut(VarSetCapacity(bi, 40, 0), bi)
   NumPut(nW, bi, 4)
   NumPut(nH, bi, 8)
   NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "UShort")
   NumPut(0, bi,16)
   Return,   DllCall("gdi32\CreateDIBSection", "UInt", hDC, "UInt", &bi, "UInt", 0, "UInt*", pBits, "UInt", 0, "UInt", 0)
}

BitBlt(DestDC, Destx, Desty, Destw, Desth, SourceDC, Sourcex, Sourcey, Raster="")
{
   If !Raster
   Raster := 0x40000000|0x00CC0020
   DllCall("gdi32\BitBlt"
   , "UInt", DestDC                  ; handle to destination DC
   , "Int", Destx                     ; x-coord of destination upper-left corner
   , "Int", Desty                     ; y-coord of destination upper-left corner
   , "Int", Destw                     ; width of destination rectangle
   , "Int", Desth                     ; height of destination rectangle
   , "UInt", SourceDC                  ; handle to source DC
   , "Int", Sourcex                  ; x-coordinate of source upper-left corner
   , "Int", Sourcey                  ; y-coordinate of source upper-left corner
   , "UInt", Raster)                  ; raster operation code
}

StretchBlt(DestDC, Destx, Desty, Destw, Desth, SourceDC, Sourcex, Sourcey, Sourcew, Sourceh, Raster="")
{
   If !Raster
   Raster := 0x00CC0020
   DllCall("gdi32\StretchBlt"
   , "UInt", DestDC                  ; handle to destination DC
   , "Int", Destx                     ; x-coord of destination upper-left corner
   , "Int", Desty                     ; y-coord of destination upper-left corner
   , "Int", Destw                     ; width of destination rectangle
   , "Int", Desth                     ; height of destination rectangle
   , "UInt", SourceDC                  ; handle to source DC
   , "Int", Sourcex                  ; x-coordinate of source upper-left corner
   , "Int", Sourcey                  ; y-coordinate of source upper-left corner
   , "Int", Sourcew                  ; width of source rectangle
   , "Int", Sourceh                  ; height of source rectangle
   , "UInt", Raster)                  ; raster operation code
}


I have been trying to figure the maths out for this for over 2 hours. I want to fill the area where the window is with black instead of it zooming in on itself. It would only be a few lines in length if I could figure it out! Dont worry if this is too boring, I'll keep it at it, but it may be a while until I figure it out Confused
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Mon Mar 24, 2008 7:16 am    Post subject: Reply with quote

Not that it has anything to do with the original topic... Rolling Eyes

Code:
   NumPut((posy+posh)-Zoomy ; bottom
      , NumPut((posx+posw)-Zoomx ; right
         , NumPut(posy-Zoomy ; top
            , NumPut(posx-Zoomx ; left
               , RC))))
It seems odd blanking out the window frame, especially since on Vista the frame has rounded corners, and the rectangle doesn't... I prefer blanking out the client area (or not at all):
Code:
   VarSetCapacity(wi, 60), NumPut(60, wi)
   ; Get the screen coordinates of the magnifier's client area.
   DllCall("GetWindowInfo", "UInt", hwnd1, "UInt", &wi)
   ; Convert to "bitmap" coordinates...
   NumPut(NumGet(wi,20,"int")-Zoomx, RC, 0)
   NumPut(NumGet(wi,24,"int")-Zoomy, RC, 4)
   NumPut(NumGet(wi,28,"int")-Zoomx, RC, 8)
   NumPut(NumGet(wi,32,"int")-Zoomy, RC, 12)
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Mon Mar 24, 2008 8:13 am    Post subject: Reply with quote

Oh snap! Amazing! Thank you so much! It looks lovely.

Yeh sorry for the topic deviation, didnt think it would be helpful to start a new help thread as there are few that could answer. Could have sent a PM, but I think it could be handy for others and people should see that you worked it out and not me Wink GDI is loosely related to GDI+ but thank you very much! saved me hours of work and pain!
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Tue Mar 25, 2008 7:48 am    Post subject: Reply with quote

Is it possible to get a pBitmap from the binary data of a png in memory?
Is it anything to do with GdipCreateBitmapFromStream if it can be done at all?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Tue Mar 25, 2008 8:42 am    Post subject: Reply with quote

Have you searched the forums? Rolling Eyes Use Google. The phpBB search function sucks.
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Tue Mar 25, 2008 9:48 am    Post subject: Reply with quote

Sweet! I have managed to get it read images directly from BRA files I have created and display them as alphablended guis.

I had tried searching for GdipCreateBitmapFromStream on this forum, but it returned nothing, so I thought you might know.

Thanks.

Function is:

Code:
pBitmapFromBRA(In, File)
{
   FileRead, FileContents, %In%
   
   If (SubStr(File, 1, 4) = "File") && (SubStr(File, 5, StrLen(File)-4) & 1 != "")
   {
      RegExMatch(FileContents, ":H:([0-9]+).*?:a:" SubStr(File, 5, StrLen(File)-4) ":b:(.*?):c:([0-9]+):d:([0-9]+)::", FileInfo)
      File := FileInfo2
   }
   Else
   RegExMatch(FileContents, ":H:([0-9]+).*?:a:([0-9]+):b:" File ":c:([0-9]+):d:([0-9]+)::", FileInfo)
   
   If !FileInfo
   Return, "The specified file was not found in the archive"
   
   h := DllCall("CreateFile", "Str", In, "UInt", 0x80000000, "UInt", 3, "UInt", 0, "UInt", 3, "UInt", 0, "UInt", 0)
   DllCall("SetFilePointerEx", "UInt", h, "Int64", FileInfo1+FileInfo4, "Int64*", p, "Int", 0)
   VarSetCapacity(Data, FileInfo3)
   result := DllCall("ReadFile", "UInt", h, "UInt", &Data, "UInt", FileInfo3, "UInt*", Read, "UInt", 0)
   h := DllCall("CloseHandle", "UInt", h)
   
   hData := DllCall("GlobalAlloc", "UInt", 2, "UInt", FileInfo3)
   pData := DllCall("GlobalLock",  "UInt", hData)
   DllCall("RtlMoveMemory", "UInt", pData, "UInt", &Data, "UInt", FileInfo3)
   DllCall("GlobalUnlock", "UInt", hData)
   DllCall("ole32\CreateStreamOnHGlobal", "UInt", hData, "Int", 1, "UInt*", pStream)
   DllCall("gdiplus\GdipCreateBitmapFromStream", "UInt", pStream, "UInt*", pBitmap)
   Return, pBitmap
}


Creates pBitmap from BRA file ready to be added to a gui Smile
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Sat May 10, 2008 7:44 pm    Post subject: Reply with quote

I am working on getting gdi+ text working, but I am a little bit stuck.

I guess the problem is with Gdip_DrawString and Gdip_MeasureString.

Any help would be greatly appreciated Smile

Code:
#SingleInstance, Force
#NoEnv

File = in.jpg
String = Hello

pToken := Gdip_Startup()

pBitmap    := Gdip_CreateBitmapFromFile(File)
G          := Gdip_GraphicsFromImage(pBitmap)
hFamily    := Gdip_FontFamilyCreate("Arial")
hFont       := Gdip_FontCreate(hFamily, 25, 1)
hFormat      := Gdip_StringFormatCreate(0x4000)
hBrush      := Gdip_BrushCreateSolid(0xff000000)
Width      := Gdip_GetImageWidth(pBitmap)
Height      := Gdip_GetImageHeight(pBitmap)

VarSetCapacity(RC, 8)
NumPut(Width, RC, 0, "Float"), NumPut(Height, RC, 4, "Float")

;aInfo      := Gdip_MeasureString(G, String, hFont, RC, hFormat)
;MsgBox, % aInfo      ;%

Gdip_DrawString(G, String, hFont, hFormat, hBrush, RC)

Gdip_SaveBitmapToFile(pBitmap, "test.png")
; Cleanup
Return

;###############################################################################################################

; http://www.news2news.com/vfp/?group=-1&function=811

; GpStatus WINGDIPAPI GdipDrawString(
    ; GpGraphics *graphics,
    ; GDIPCONST WCHAR *string,
    ; INT length,
    ; GDIPCONST GpFont *font,
    ; GDIPCONST RectF *layoutRect,
    ; GDIPCONST GpStringFormat *stringFormat,
    ; GDIPCONST GpBrush *brush
; )
 
Gdip_DrawString(hGraphics, sString, hFont, hFormat, hBrush, RectF)
{
   nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0)
   VarSetCapacity(wString, nSize*2)
   DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize)
   
   E := DllCall("gdiplus\GdipDrawString", "UInt", hGraphics, "UInt", &wString, "Int", -1, "UInt", &hFont, "UInt", RectF, "UInt", &hFormat, "UInt", hBrush)
   Return, E ? E : 0
}

; http://www.news2news.com/vfp/?group=115&function=1015

; GpStatus WINGDIPAPI GdipMeasureString(
    ; GpGraphics *graphics,
    ; GDIPCONST WCHAR *string,
    ; INT length,
    ; GDIPCONST GpFont *font,
    ; GDIPCONST RectF *layoutRect,
    ; GDIPCONST GpStringFormat *stringFormat,
    ; RectF *boundingBox,
    ; INT *codepointsFitted,
    ; INT *linesFilled
; )

Gdip_MeasureString(hGraphics, sString, hFont, Layout, hFormat)
{
   nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", 0, "Int", 0)
   VarSetCapacity(wString, nSize*2)   
   DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sString, "Int", -1, "UInt", &wString, "Int", nSize)
   VarSetCapacity(SizeF, 8)
   
   DllCall("gdiplus\GdipMeasureString", "UInt", hGraphics, "UInt", &wString, "Int", -1, "UInt", &hFont, "UInt", &Layout, "UInt", &hFormat, "UInt", &SizeF, "UInt", 0, "UInt", 0)
   Return, Layout ? Layout : 0
}

;###############################################################################################################

Gdip_SaveBitmapToFile(pImage, sOutput)
{
    StringSplit, OutputArray, sOutput, .
    Extension := "." . OutputArray%OutputArray0%
   If Extension not in .png,.bmp,.jpg,.tiff,.gif
   Return, -1
   
   DllCall("gdiplus\GdipGetImageEncodersSize", "UInt*", nCount, "UInt*", nSize)
    VarSetCapacity(ci, nSize)
    DllCall("gdiplus\GdipGetImageEncoders", "UInt", nCount, "UInt", nSize, "UInt", &ci)
   If !(nCount && nSize)
   Return, -5
   
    Loop, %nCount%
    {
        nSize := DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76*(A_Index-1)+44), "Int", -1, "UInt", 0, "Int",  0, "UInt", 0, "UInt", 0)
        VarSetCapacity(sString, nSize)
        DllCall("WideCharToMultiByte", "UInt", 0, "UInt", 0, "UInt", NumGet(ci, 76*(A_Index-1)+44), "Int", -1, "Str", sString, "Int", nSize, "UInt", 0, "UInt", 0)
   
        If !InStr(sString, Extension)
        Continue
        pCodec := &ci+76*(A_Index-1)
        Break
    }
   If !pCodec
   Return, -6
   
   nSize := DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sOutput, "Int", -1, "UInt", 0, "Int", 0)
   VarSetCapacity(wOutput, nSize*2)
   DllCall("MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sOutput, "Int", -1, "UInt", &wOutput, "Int", nSize)
   VarSetCapacity(wOutput, -1)
   If !VarSetCapacity(wOutput)
   Return, -7

   E := DllCall("gdiplus\GdipSaveImageToFile", "UInt", pImage, "UInt", &wOutput, "UInt", pCodec, "UInt", 0)
   Return, E ? -8 : 0
}

Gdip_GetImageWidth(pImage)
{
   DllCall("gdiplus\GdipGetImageWidth", "UInt", pImage, "UInt*", Width)
   Return, Width
}

Gdip_GetImageHeight(pImage)
{
   DllCall("gdiplus\GdipGetImageHeight", "UInt", pImage, "UInt*", Height)
   Return, Height
}

Gdip_BrushCreateSolid(ARGB=0xff000000)
{
   DllCall("gdiplus\GdipCreateSolidFill", "Int", ARGB, "UInt*", hBrush)
   Return, hBrush
}
 
Gdip_StringFormatCreate(Format=0, Lang=0)
{
   DllCall("gdiplus\GdipCreateStringFormat", "Int", Format, "Int", Lang, "UInt*", hFormat)
   Return, hFormat
}

Gdip_FontCreate(hFamily, Size, Style=0)
{
   DllCall("gdiplus\GdipCreateFont", "UInt", hFamily, "Float", Size, "Int", Style, "UInt*", hFont)
   Return, hFont
}

Gdip_FontFamilyCreate(Font)
{
   DllCall("gdiplus\GdipCreateFontFamilyFromName", "Str", Font, "UInt", 0, "UInt*", hFamily)
   Return, hFamily
}

Gdip_CreateBitmapFromFile(sFile)
{
   VarSetCapacity(wFile, 1023)
   DllCall("kernel32\MultiByteToWideChar", "UInt", 0, "UInt", 0, "UInt", &sFile, "Int", -1, "UInt", &wFile, "Int", 512)
   DllCall("gdiplus\GdipCreateBitmapFromFile", "UInt", &wFile, "UInt*", pBitmap)
   Return, pBitmap
}

Gdip_GraphicsFromImage(pImage)
{
    DllCall("gdiplus\GdipGetImageGraphicsContext", "UInt", pImage, "UInt*", pGraphics)
    Return, pGraphics
}

Gdip_Startup()
{
   If !DllCall("GetModuleHandle", "Str", "gdiplus")
   DllCall("LoadLibrary", "Str", "gdiplus")
   VarSetCapacity(si, 16, 0), si := Chr(1)
   DllCall("gdiplus\GdiplusStartup", "UInt*", pToken, "UInt", &si, "UInt", 0)
   VarSetCapacity(si, 0)
   Return, pToken
}

Gdip_Shutdown(pToken)
{
   DllCall("gdiplus\GdiplusShutdown", "UInt", pToken)
   If hModule := DllCall("GetModuleHandle", "Str", "gdiplus")
   DllCall("FreeLibrary", "UInt", hModule)
   Return, 0
}
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Sat May 10, 2008 11:53 pm    Post subject: Reply with quote

You've guessed right. I suggest you go back to the documentation and check each parameter.
  • When you pass a structure to a function, it must be passed ByRef or as an &address. (RC, RectF.)
  • When you pass the address of a pointer where the pointer itself is expected, it will not work. (hFont, hFormat.)

I also suggest you stop using the "h" prefix since it is typically used to indicate a "handle." GDI+ uses pointers, not handles.
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Wed May 21, 2008 4:04 pm    Post subject: Reply with quote

thansk for the help getting the new TextToImage to work. I will update the actual post when i release the gdi+ library i have been completing.

I'm having a problem however:

I have been trying to clip a region so that i can replace part of an image without redrawing the entire thing.

I have created:

Code:
; Replace = 0
; Intersect = 1
; Union = 2
; Xor = 3
; Exclude = 4
; Complement = 5
Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0)
{
   Return, DllCall("gdiplus\GdipSetClipRect", "UInt", pGraphics, "Float", x, "Float", y, "Float", w, "Float", h, "Int", CombineMode)
}


I have also first created a gdi+ bitmap.

I then set the clipping region to default "replace" and attempt to draw a rectangle the full size of the bitmap.
The rectangle is only drawn in the clipping region i specified, however it has not replaced that regions contents, but has drawn over them. Any ideas?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Thu May 22, 2008 5:50 am    Post subject: Reply with quote

Try setting the compositing mode to "copy" instead of "over" (blend).
Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1375

PostPosted: Thu May 22, 2008 6:12 am    Post subject: Reply with quote

Nope that didn't work Sad

Here's the full example so you can visualise it going wrong:

http://www.autohotkey.net/~tic/CipRectTest.zip

As you hover over each button I have made it fill the Graphics with a red rectangle (as i have set clipping, it only fills the button you are hovering over) The problem with that is that its drawing over it. The reason I am converting from a G obtained using a gdi+ bitmap to a gdi bitmap every iteration is because i thought that perhaps the reason it wasnt working was that it was a gdi bitmap (clutching at straws)

Thanks Lex..
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2739
Location: Australia, Qld

PostPosted: Thu May 22, 2008 10:09 am    Post subject: Reply with quote

Quote:
Nope that didn't work Sad
I wonder why?
Quote:
Code:
Gdip_SetCompositingMode(pGraphics, CompositingMode)
{
   Return, DllCall("gdiplus\GdipSetSmoothingMode", "UInt", pGraphics, "Int", CompositingMode)
}
Laughing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3 ... , 11, 12, 13  Next
Page 12 of 13

 
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