AutoHotkey Community

It is currently May 27th, 2012, 1:12 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 15, 16, 17, 18, 19, 20, 21 ... 67  Next
Author Message
 Post subject:
PostPosted: September 12th, 2009, 12:11 am 
Offline

Joined: March 11th, 2006, 12:44 pm
Posts: 341
Location: Munich, Germany
Wow, really nice work with the GDI Libray. Didnt visit the forum for some time, but there is really something going on here. Looks so much more friendly for beginners to use GDI and have fun with it. Also the examples give a good start. Haha, i can remember some folks here in the forum had the opinion that these "Wrapper" - Libraries are of no use as they slow things down ;) . I can remember many requests to copy a screenshot to a file, now its a piece of cake and only a handfull of code. I will check the Examples as it looks there is quite something to learn here. thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 9:15 pm 
I am using this function to mask('clip') out part of my bitmap :)

Code:

Gdip_SetCompositingMode(G,1)
hBrush := Gdip_BrushCreateSolid(0x0)
Gdip_FillRectangle(G,hBrush,0,0,200,200)
Gdip_DeleteBrush(hBrush)



It will only handle basic rectangle shapes.

... but I would love for this function to take a more complex bitmap shape as a mask, like a star or some shape, and do the same thing. Is this kind of action possible? :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2009, 4:03 am 
Offline

Joined: February 11th, 2007, 4:10 pm
Posts: 185
tic, can u help me about this problem?

http://www.autohotkey.com/forum/viewtop ... ht=#294544


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2009, 12:36 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
oGENEo if you wanted to use exactly the same method then you could use:

Code:
Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0)


however, this will give jagged edges.

hughman I dont understand why you want to get it onto a dc??

Just use:

Code:
Gdip_BitmapFromScreen(Screen=0, Raster="")


once you have the coordinates of the area you want to capture. If the window is going to be behind other windows then use:

Code:
Gdip_BitmapFromHWND(hwnd=0)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 16th, 2009, 3:03 pm 
hi
i made an window with gdi+ library, but if i try to add something like gui, add, ext it wont work, is there any work-around?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 19th, 2009, 4:44 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
I attempted to combine the effects of tutorial #8 and #10 to make text over graphics
And am happy, so far, with my attempt. I just wanted to share the change if it might help someone else.
I compared the two examples and found similarities:

I found in Gdip.Tutorial.8-Write.text.onto.a.gui
Code:
; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height)

I found in Gdip.Tutorial.10-Rotate.Flip.or.Mirror.an.image
Code:
; We will update the hwnd  with the hdc of our gdi bitmap. We are drawing it at the new width and height and in the centre of the screen
UpdateLayeredWindow(hwnd2, hdc, (A_ScreenWidth-RWidth)//2, (A_ScreenHeight-RHeight)//2, RWidth, RHeight)


I took the following lines from Tutorial #8 (draw text) approximately lines 44-105 and inserted them into the listing for tutotial #10 after line 127.
Some line were commented out because I didn't want that feature, rounded rectangle for instance.
Code:
;==========================================================================
; taken from Gdip.Tutorial.8-Write.text.onto.a.gui.ahk
;==========================================================================


; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)

; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
;;pBrush := Gdip_BrushCreateSolid(0xaa000000)

; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
;Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20)

; Delete the brush as it is no longer needed and wastes memory
;Gdip_DeleteBrush(pBrush)

; We can specify the font to use. Here we use Arial as most systems should have this installed
Font = Arial
; Next we can check that the user actually has the font that we wish them to use
; If they do not then we can do something about it. I choose to give a wraning and exit!
If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

; There are a lot of things to cover with the function Gdip_TextToGraphics

; The 1st parameter is the graphics we wish to use (our canvas)

; The 2nd parameter is the text we wish to write. It can include new lines `n

; The 3rd parameter, the options are where all the action takes place...
; You can write literal x and y coordinates such as x20 y50 which would place the text at that position in pixels
; or you can include the last 2 parameters (Width and Height of the Graphics we will use) and then you can use x10p
; which will place the text at 10% of the width and y30p which is 30% of the height
; The same percentage marker may be used for width and height also, so w80p makes the bounding box of the rectangle the text
; will be written to 80% of the width of the graphics. If either is missed (as I have missed height) then the height of the bounding
; box will be made to be the height of the graphics, so 100%

; Any of the following words may be used also: Regular,Bold,Italic,BoldItalic,Underline,Strikeout to perform their associated action

; To justify the text any of the following may be used: Near,Left,Centre,Center,Far,Right with different spelling of words for convenience

; The rendering hint (the quality of the antialiasing of the text) can be specified with r, whose values may be:
; SystemDefault = 0
; SingleBitPerPixelGridFit = 1
; SingleBitPerPixel = 2
; AntiAliasGridFit = 3
; AntiAlias = 4

; The size can simply be specified with s

; The colour and opacity can be specified for the text also by specifying the ARGB as demonstrated with other functions such as the brush
; So cffff0000 would make a fully opaque red brush, so it is: cARGB (the literal letter c, follwed by the ARGB)

; The 4th parameter is the name of the font you wish to use

; As mentioned previously, you don not need to specify the last 2 parameters, the width and height, unless
; you are planning on using the p option with the x,y,w,h to use the percentage
Options = x10p y30p w80p Centre cbbffffff r4 s20 Underline Italic
Gdip_TextToGraphics(G, "Tutorial 8`n`nThank you for trying this example", Options, Font, Width, Height)





;==========================================================================
;==========================================================================


Now if I can only figure out how to create a larger contrasting shadow, I'm all set!
Leef_me


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2009, 9:08 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
Wow! Did I accidentally poison the waterhole?

The GDI+ thread was buzzing just a few days ago, and now it's a ghost town.

I kinda feel like the big bird in Pixar's "For the Birds"
http://video.google.com/videoplay?docid ... APLuvSKBg#


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2009, 11:29 am 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Yo....post your full code and let me take a butchers


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 29th, 2009, 5:17 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
tic wrote:
Yo....post your full code and let me take a butchers

I think you misunderstood my last post. I was dissapointed to not see anyone elses posts in this thread for 10 days.

Concerning my prior post, I have have paused that chain of action while looking into another matter.

Could you help with that thread?
http://www.autohotkey.com/forum/viewtop ... highlight=

Thanks in advance

Leef_me


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 15th, 2009, 9:04 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
I am unsure if I should post this to ASK or to the GDIP thread of Scripts & Funtions.

I am looking for a few features that I didn't find examples for, nor it seems in the GDIP.ahk file.
I have done a search of the forum and came up empty.

The features I am looking for are:
gradiant shaded coloring of a shape, such as rectangle
text outlining and shadowing

I would also like to find a definition of "LayeredWindow" since the term UpdateLayeredWindow is used in GDIP.ahk and the examples.

Thanks in advance

Leef_me


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 16th, 2009, 9:38 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Leef_me wrote:
gradiant shaded coloring of a shape, such as rectangle
Use Gdip_CreateLineBrushFromRect to create a gradient brush, then pass it to an appropriate shape-drawing function (such as Gdip_FillRectangle).
Quote:
text outlining
The easiest way is to draw the "outline" first, by drawing the same text four times at different offsets. Another way is to create a GradientPath from some text, then draw along the path (i.e. outline) - that's actually slower though.
Quote:
and shadowing
Again, the easiest way is to draw the shadow first, by simply drawing the same text a different colour and at a slight offset.
Quote:
I would also like to find a definition of "LayeredWindow"
See Layered Windows (article) or UpdateLayeredWindow or Layered Windows (documentation).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2009, 10:45 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
tkoi wrote:
tic, I think SetImage() should return ErrorLevel. Currently it returns nothing. This came to my attention because I just spent 20 minutes trying to figure out why my script was leaking 256kb and a GDI object every time a certain routine was called. Turns out, STM_SETIMAGE returns a handle to a copy of the bitmap that was previously set to the static control (or NULL if none).

See MSDN: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Quote:
Important

In version 6 of the Microsoft Win32 controls, a bitmap passed to a static control using the STM_SETIMAGE message was the same bitmap returned by a subsequent STM_SETIMAGE message. The client is responsible to delete any bitmap sent to a static control.

With Microsoft Windows XP, if the bitmap passed in the STM_SETIMAGE message contains pixels with non-zero alpha, the static control takes a copy of the bitmap. This copied bitmap is returned by the next STM_SETIMAGE message. The client code may independently track the bitmaps passed to the static control, but if it does not check and release the bitmaps returned from STM_SETIMAGE messages, the bitmaps are leaked.


tkoi you mentioned this some time ago and Im sorry for overlooking this as this is obviously a priority change to the library. I will change the function to:

Code:
SetImage(hwnd, hBitmap)
{
   SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
   E := ErrorLevel
   DeleteObject(E)
   return E
}


Does anyone have any reasons they would like the created bitmap to not just be disposed of?


Last edited by tic on November 15th, 2009, 5:15 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: outlined text
PostPosted: November 15th, 2009, 4:29 pm 
Offline

Joined: May 22nd, 2009, 2:48 pm
Posts: 12
http://www.codeproject.com/KB/GDI-plus/OutlineText.aspx

This looks fantastic!

Image

Image

can somebody show in ahk?
looking forword to your help!
thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 5:40 pm 
Offline

Joined: April 30th, 2009, 12:35 pm
Posts: 29
I suppose you were too lazy to read the whole thread?

http://www.autohotkey.com/forum/viewtop ... ht=#287985

I've improved it slightly from then. See here for the full EXE. And here for the (cutdown) code:

Code:
; See Here http://www.autohotkey.com/forum/viewtopic.php?p=287985#287985
; Don't forget to change the GDIP.AHK -->  Gdip_TextToGraphics
;
;   If vPos
;   {
;      StringSplit, ReturnRC, ReturnRC, |
;     
;      If (vPos = "vCentre") || (vPos = "vCenter")
;      ypos := ypos + (Height-ReturnRC4)//2
;
; COMMENT THIS OUT      Else If (vPos = "Top") || (vPos = "Up")
; COMMENT THIS OUT      ypos := 0
;      Else If (vPos = "Bottom") || (vPos = "Down")
;      ypos := ypos + Height-ReturnRC4
;     
;      CreateRectF(RC, xpos, ypos, Width, ReturnRC4)
;   }
;
;

#SingleInstance,Ignore
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

   Save_BatchLines = %A_BatchLines%

   DetectHiddenWindows On
   
; Start gdi+
   If !pToken := Gdip_Startup()
   {
      MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
      GoSub,GUIClose
   }

;---------------------------------------

   ApplicationName=Clown_SRT2XMLSUB
   ApplicationVersion=v0.06
   ApplicationTitle=%ApplicationName% %ApplicationVersion%
   
   DetectHiddenWindows, On

   GoSub,Define_Gui
   
   GoSub,Main_Brain
   
Return

;---------------------------------------

GUIClose:

; gdi+ may now be shutdown on exiting the program
   Gdip_Shutdown(pToken)
   
   ExitApp

Return

;---------------------------------------

GoClownBD:

   Run,http://www.clownbd.com/,,UseErrorLevel

Return

;---------------------------------------

Main_Brain:

   Current_GUI = 2

   Gui,%Current_GUI%:Default
   Cur_Win_title = %ApplicationTitle%
   Gui,Show,,%Cur_Win_title%

Return

;---------------------------------------

Gui_Submit_Nohide:

   Gui,Submit,nohide

   if Border = 0
      GuiControl,Hide,BColour
   else
      GuiControl,Show,BColour

Return

;---------------------------------------

Preview_PNG:

   Gui,Submit,nohide
   
   Text := ApplicationTitle . "`n" . Font . " " . Size . " " . Style . " Preview"
   
;-- Build temporary window to determine maximum width
   Gui 3:-Caption
   gui 3:Margin,0,0
   gui 3:Font,s%Size%,%Font%
   gui 3:Add,Text,,%Text%
   gui 3:Show,Hide  ;-- Render but don't show

;-- How wide is it?
   gui 3:+LastFound
   WinGetPos ,,,Width,Height,% "ahk_id " . WinExist()
   gui 3:Destroy
   
; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
   Gui, 4: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs

; Show the window
   Gui, 4: Show, NA

; Get a handle to this window we have created in order to update it later
   hwnd1 := WinExist()

; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
   hbm := CreateDIBSection(A_ScreenWidth, A_ScreenHeight)

; Get a device context compatible with the screen
   hdc := CreateCompatibleDC()

; Select the bitmap into the device context
   obm := SelectObject(hdc, hbm)

; Get a pointer to the graphics of the bitmap, for use with drawing functions
   G := Gdip_GraphicsFromHDC(hdc)

; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
   Gdip_SetSmoothingMode(G, 4)

   WriteText(G, Text, Size, Align, vPos, Font, Colour, "ff", Style, Border, BColour,  Width, Height)

   if SAlign = Left
   {
      TextToImage_X := 0 + Htolerance
   }
   if SAlign = Centre
   {
      TextToImage_X := ((A_ScreenWidth - Width) // 2) + Htolerance
   }
   if SAlign = Right
   {
      TextToImage_X := A_ScreenWidth - Width + Htolerance
   }
   if SvPos = Top
   {
      TextToImage_Y := 0 + Vtolerance
   }
   if SvPos = vCentre
   {
      TextToImage_Y := ((A_ScreenHeight - Height) // 2) + Vtolerance
   }
   if SvPos = Bottom
   {
      TextToImage_Y := A_ScreenHeight - Height + Vtolerance
   }

; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
; So this will position our gui at (0,0) with the Width and Height specified earlier
   UpdateLayeredWindow(hwnd1, hdc, TextToImage_X, TextToImage_Y, Width, Height)

; Select the object back into the hdc
   SelectObject(hdc, obm)

; Now the bitmap may be deleted
   DeleteObject(hbm)

; Also the device context related to the bitmap may be deleted
   DeleteDC(hdc)

   Settimer,Kill_Preview,15000
   
Return

;---------------------------------------

Kill_Preview:

   Settimer,Kill_Preview,Off
   Gui, 4:Destroy
   
Return


;---------------------------------------

Define_Gui:

   Gui,Destroy

   Gui,1:Add,Text
   Gui,1:+LastFound
   WinSet,Transparent,0
   WinSet,ExStyle,^0x20
   Gui,1:-Caption
   Gui,1:Show, w%A_ScreenWidth% h%A_ScreenHeight%,%ApplicationTitle%

   Gui,2:Default
   Gui,+owner1
   Gui,+owner
   Gui -SysMenu

   Gui,Add,Text,y+15

   Gui,Add,GroupBox,Section w450 h55 xm yp,Font Name - Font Size - Font Style - Font Colour
   Gui,Add,DropDownList, xs+10 w100 ys+20 vFont gGui_Submit_Nohide,Arial||Courier New|Impact|Lucida Console|Tahoma|Times New Roman|
   Gui,Add,DropDownList, xp+110 w100 yp vSize gGui_Submit_Nohide,24|30|36|40|48|60||72|
   Gui,Add,DropDownList, xp+110 w100 yp vStyle gGui_Submit_Nohide,Regular||Bold|Italic|BoldItalic|Underline|Strikeout
   Colour = ffffff
   Gui, Add, ListView, xp+110 w100 r1 yp ReadOnly 0x4000 +Background%Colour% vColour gChoose_Color

   Gui,Add,Text,y+20

   Gui,Add,GroupBox,Section w450 h55 xm yp,Border Thickness - Border Colour - Text Horizontal Alignment - Text Vertical Alignment
   Gui,Add,DropDownList, xs+10 w100 ys+20 vBorder gGui_Submit_Nohide,0|1|2||3|
   BColour = 000000
   Gui, Add, ListView, xp+110 w100 r1 yp ReadOnly 0x4000 +Background%BColour% vBColour gChoose_Color
   Gui,Add,DropDownList, xp+110 w100 yp vAlign gGui_Submit_Nohide,Left|Centre||Right|
   Gui,Add,DropDownList, xp+110 w100 yp vvPos gGui_Submit_Nohide,Top||Bottom|vCentre

   Gui,Add,Text,y+20

   Gui,Add,GroupBox,Section w450 h55 xm yp,Horizontal Alignment - Horizonal Tolerance - Vertical Alignment - Vertical Tolerance
   Gui,Add,DropDownList, xs+10 w100 ys+20 vSAlign gGui_Submit_Nohide,Left|Centre||Right|
   Gui,Add,Slider,xp+110 w100 yp Tooltip vHTolerance Range-100-100, 0
   Gui,Add,DropDownList, xp+110 w100 yp vSvPos gGui_Submit_Nohide,Top|Bottom||vCentre
   Gui,Add,Slider,xp+110 w100 yp Tooltip vVTolerance Range-100-100, -30

   Gui,Add,Text,y+20

   Gui,Add,Button,xm yp w75 r1 vGuiClose gGuiClose,Exit
   Gui,Add,Button,xm+85 yp w75 r1 vGoClownBD gGoClownBD,About
   Gui,Add,Button,xm+290 yp w75 r1 vButton_Preview gPreview_PNG,Preview

   Gui,Add,StatusBar, vStatusBar

   OnMessage(0x200, "WM_MOUSEMOVE")
   OnMessage(0x201, "WM_LBUTTONDOWN")
   
   SizeOfStructForChooseColor = 0x24
   VarSetCapacity(StructForChooseColor, SizeOfStructForChooseColor, 0)
   VarSetCapacity(StructArrayForChooseColor, 64, 0)

   Gui, +LastFound
   GuiHWND := WinExist()  ; Relies on the line above to get the unique ID of GUI window.

   InsertInteger(SizeOfStructForChooseColor, StructForChooseColor, 0)  ; DWORD lStructSize
   InsertInteger(GuiHWND, StructForChooseColor, 4)  ; HWND hwndOwner (makes dialog "modal").
   InsertInteger(0x0 ,    StructForChooseColor, 8)  ; HINSTANCE hInstance
   InsertInteger(0x0 ,    StructForChooseColor, 12)  ; clr.rgbResult =  0;
   InsertInteger(&StructArrayForChooseColor , StructForChooseColor, 16)  ; COLORREF *lpCustColors
   InsertInteger(0x00000100 , StructForChooseColor, 20)  ; Flag: Anycolor
   InsertInteger(0x0 ,    StructForChooseColor, 24)  ; LPARAM lCustData
   InsertInteger(0x0 ,    StructForChooseColor, 28)  ; LPCCHOOKPROC lpfnHook
   InsertInteger(0x0 ,    StructForChooseColor, 32)  ; LPCTSTR lpTemplateName

   Font_TT =  The name of the true type font.
   Size_TT =  The size of the true type font.
   Style_TT =  The style of the true type font.
   Colour_TT =  The colour of the true type font.`nYou can click the box and get a colour picker.

   Border_TT =  The thickness of the border (if any).
   BColour_TT =  The colour of the border.`nYou can click the box and get a colour picker.
   Align_TT =  The horizontal alignment of the text within it's own area. Not to be confused with the final screen position.
   vPos_TT =  The vertical alignment of the text within it's own area. Not to be confused with the final screen position.
   
   SAlign_TT =  The horizontal alignment of the subtitles on screen. Not to be confused with the text alignment.
   HTolerance_TT = The number of pixels left or right from left/center/right of screen
   SvPos_TT =  The vertical alignment of the subtitles on screen. Not to be confused with the final text alignment.   
   VTolerance_TT = The number of pixels up or down from top/center/bottom of screen
   
   GuiClose_TT = Bye Bye !
   GoClownBD_TT =  Visit my webpage.
   Button_Preview_TT =  Show a preview of your selected text on-screen.`nPreview will autoclose in 10 seconds.

   StatusBar_TT = There is nothing to see here, please move along.

Return

Choose_Color:

   nRC := DllCall("comdlg32\ChooseColorA", str, StructForChooseColor)  ; Display the dialog.
   if (errorlevel <> 0) || (nRC = 0)
   {
;~       MsgBox error while calling ChooseColor Errorlevel: %errorlevel% - RC: %nRC%
      return
   }
   ; Otherwise, the user pressed OK in the dialog, so determine what was selected.
   ;GuiControl,, Color, % BGRtoRGB(ExtractInteger(StructForChooseColor, 12))
   SetFormat, integer, hex  ; Show RGB color extracted below in hex format.
   New_Colour = % BGRtoRGB(ExtractInteger(StructForChooseColor, 12))
   GuiControl,+Background%New_Colour% , % A_GuiControl
   %A_GuiControl% = %New_Colour%
   SetFormat, integer, d

Return

ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
; See DllCall documentation for details.
{
   SourceAddress := &pSource + pOffset  ; Get address and apply the caller's offset.
   result := 0  ; Init prior to accumulation in the loop.
   Loop %pSize%  ; For each byte in the integer:
   {
      result := result | (*SourceAddress << 8 * (A_Index - 1))  ; Build the integer from its bytes.
      SourceAddress += 1  ; Move on to the next byte.
   }
   if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
      return result  ; Signed vs. unsigned doesn't matter in these cases.
   ; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
   return -(0xFFFFFFFF - result + 1)
}

InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4)
; To preserve any existing contents in pDest, only pSize number of bytes starting at
; pOffset are altered in it. The caller must ensure that pDest has sufficient capacity.
{
   mask := 0xFF  ; This serves to isolate each byte, one by one.
   Loop %pSize%  ; Copy each byte in the integer into the structure as raw binary data.
   {
      DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1  ; Write one byte.
         , UChar, (pInteger & mask) >> 8 * (A_Index - 1))  ; This line is auto-merged with above at load-time.
      mask := mask << 8  ; Set it up for isolation of the next byte.
   }
}

WriteText(G="", Text="TextToImage", Size="20", Align="Bottom|Centre", vPos="Top", Font="Arial", Colour="ffffff", Transparancy="ff", Style="", Border="0", BColour="000000",  Width="", Height="")
{

   if Border > 0
   {
      Options = %Align% %vPos% w%Width% h%Height% r4 c%Transparancy%%BColour% s%Size% %Style%
      Border_IDX1 := 0 - Border
      Loop,2
      {
         If Border_IDX1 > %Border%
               Break
         Border_IDX2 := 0 - Border
         Loop
         {
               If Border_IDX2 > %Border%
                     Break
               BOptions = x%Border_IDX1% y%Border_IDX2% %Options%
               Gdip_TextToGraphics(G,TEXT,BOptions,Font)
               BOptions = x%Border_IDX2% y%Border_IDX1% %Options%
               Gdip_TextToGraphics(G,TEXT,BOptions,Font)
               Border_IDX2++
         }
         Border_IDX1 := 0 + Border
      }
   }
   Options = %Align% %vPos% w%Width% h%Height% c%Transparancy%%Colour% r4 s%Size% %Style%
   Gdip_TextToGraphics(G,TEXT,Options,Font)

   return
}

BGRtoRGB(oldValue)
{

  Value := (oldValue & 0x00ff00)
  Value += ((oldValue & 0xff0000) >> 16)
  Value += ((oldValue & 0x0000ff) << 16)
  return Substr("000000" . substr(Value,3),-5)

}

WM_MOUSEMOVE()

{
   static CurrControl, PrevControl, _TT  ; _TT is kept blank for use by the ToolTip command below.
   CurrControl := A_GuiControl
   If (CurrControl <> PrevControl and not InStr(CurrControl, " "))
   {
      ToolTip  ; Turn off any previous tooltip.
      SetTimer, DisplayToolTip, 2000
      PrevControl := CurrControl
   }
   
   return
   
   DisplayToolTip:
   
   SetTimer, DisplayToolTip, Off
   Tooltip_Text = % %CurrControl%_TT
   Tooltip_Text := RegExReplace(Tooltip_Text,"\[CR\]","`n")
   ToolTip %Tooltip_Text%
   SetTimer, RemoveToolTip, 5000
   
   return
   
   RemoveToolTip:
      
      SetTimer, RemoveToolTip, Off
      ToolTip
      
   return
}

WM_LBUTTONDOWN()
{
   if (A_GuiControl = "Colour") or (A_GuiControl = "BColour")
      Gosub,Choose_Color
      
   return
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2009, 2:32 pm 
Offline

Joined: May 22nd, 2009, 2:48 pm
Posts: 12
Thanks for your code, mrr19121970.
It looks nice. thanks.

but it looks a little bit rugged, probably due to rendering quality R1
the text quality is way below what is expected from GDIPlus.
I wouldn't go with Gdiplus for that quality. It can be done only with normal text control.

what i wanna know was addpathstring fuction in ahk 'cause it's missing in gdip.ahk.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1000 posts ]  Go to page Previous  1 ... 15, 16, 17, 18, 19, 20, 21 ... 67  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon and 16 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