Advertisement
pastamaker

havoc v1.4

Jun 25th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  5.  
  6.  ;~ #Include,<hellbents_gdip>
  7.  SetBatchLines,-1
  8.  #MaxHotkeysPerInterval,10000000000
  9.  popUp:=Layered_Window_SetUp(4,0,0,A_ScreenWidth,A_ScreenHeight,1,"Alwaysontop")
  10.  
  11.  
  12.  back:=new BackClass
  13.  x1:=10 ,   x2:=500,    y1:=10 , y2:=500 ,colour:="ffffff",colour2:="000000"
  14.  back.set(x1,y1,x2,y2,colour,colour2)
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  boxes:= new BoxesClass
  22.  boxes.setup(back)
  23.  boxes.add(60,60,100,100,"ff0000",0)
  24.  boxes.add(200,200,300,300,"00ffa0",0)
  25.     boxes.add(120,60,150,90,"f0ff14",1)
  26.   boxes.add(70,150,190,250,"00ff0f",1)
  27.     boxes.add(300,50,350,75,"AE94D1",1)
  28.       boxes.add(250,350,285,380,"DFD84B",1)
  29.  
  30.  
  31.  SetTimer,mainloop,10
  32.  dx:=10, dy:=10
  33.  return
  34.  mainloop:
  35. boxes.borderv:=0
  36. boxes.inside()
  37.  Gdip_GraphicsClear(popUp.g)
  38.  
  39.   back.draw(popup)
  40. ( getkeystate("w"))?(boxes.boxes[boxes.nbox].move(0,-dy)):( getkeystate("s"))?(boxes.boxes[boxes.nbox].move(0,dy)):( getkeystate("a"))?(boxes.boxes[boxes.nbox].move(-dx,0)):( getkeystate("d"))?(boxes.boxes[boxes.nbox].move(dx,0))
  41. boxes.turn(boxes.nbox)
  42.  ;~ boxes.myInterrupt(1,2)
  43. ;~ ToolTip,% boxes.boxes[1].previous.x1 " new: " boxes.boxes[1].x1
  44. ;~ boxes.automove(1)
  45. boxes.collapse(boxes.nbox)
  46.  
  47.  
  48.  
  49. boxes.automove()
  50.  
  51.  
  52.  
  53. boxes.turnBack()
  54.  
  55.  
  56. boxes.draw(popup.g)
  57.  
  58.  UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
  59.  boxes.tocurrent()
  60.  
  61.  
  62.  return
  63.  
  64.  
  65.  
  66.  class Box {
  67.     set(x1,y1,x2,y2,colour,blocked){
  68.         this.x1:=x1,    this.x2:=x2,    this.y1:=y1,    this.y2:=y2
  69.         this.map:=this.makemap(colour)
  70.         this.previous:={x1:x1,x2:x2,y1:y1,y2:y2}
  71.         this.blocked:=blocked
  72.     }
  73.     getcentre(ByRef x3,ByRef y3){
  74.         x3:=(this.x1 + this.x2 )/2,     y3:=(this.y1 + this.y2 )/2
  75.     }
  76.     getsize(ByRef w, ByRef h){
  77.         w:=this.x2 - this.x1,   h:=this.y2 - this.y1   
  78.     }
  79.     draw(g){
  80.         this.getsize(w,h)
  81.        
  82.         Gdip_DrawImage(g, this.map,this.x1,this.y1,w,h)
  83.         if(this.blocked = 1)
  84.             fill_ellipse(g,"000000",this.x1+1,this.y1+1,w-3,h-3)
  85.        
  86.     }
  87.     makemap(colour){
  88.         this.getsize(w,h)
  89.         map:=Gdip_CreateBitmap(w, h)
  90.         g:=Gdip_GraphicsFromImage(map)
  91.         fill_boxx(g,colour,0,0,w,h)
  92.         return map
  93.     }
  94.     tocurrent(){
  95.         this.previous:={x1:this.x1,x2:this.x2,y1:this.y1,y2:this.y2}
  96.     }
  97.     move(dx,dy){
  98.         this.x1+=dx,    this.x2+=dx,    this.y1+=dy,    this.y2+=dy
  99.     }
  100.     inside(x,y){
  101.         if(x>this.x1 && x< this.x2 && y > this.y1 && y< this.y2)
  102.             return true
  103.         return false
  104.     }
  105.     toggleblocked(){
  106.        
  107.         this.blocked:=abs(this.blocked - 1)
  108.        
  109.     }
  110.    
  111.  
  112. }
  113.  
  114.  
  115.  class BoxesClass {
  116.     turn(nbox){
  117.         ;~ MsgBox,%     this.back.size.x1
  118.         ;~ global popup
  119.          ;~ Layered_Window_ShutDown(popUp)
  120.         ;~ ExitApp
  121.         this.turnv:=1
  122.         vx:=this.boxes[nbox].x1  -  this.boxes[nbox].previous.x1 ,vy:=this.boxes[nbox].y1  -  this.boxes[nbox].previous.y1
  123.         (vx > 0 )?(this.turnV:=1):(vy > 0 )?(this.turnV:=2):(vx < 0 )?(this.turnV:=3):(vy < 0 )?(this.turnV:=4)
  124.         this.backTemp:=this.back.clone()
  125.         if(this.turnV = 1)
  126.             return
  127.         else if(this.turnV = 2){
  128.            
  129.             for i,value in this.boxes {
  130.                 ;~ MsgBox,%     this.backTemp.size.x2 - (   value.x1 - this.backTemp.size.x1)
  131.                 value:=value.clone()
  132.                 previous:=value.previous.clone()
  133.                 this.boxes[i].x1:=  value.y1
  134.                 this.boxes[i].x2:= value.y2
  135.                 this.boxes[i].y1:=  value.x1
  136.                 this.boxes[i].y2:= value.x2
  137.                
  138.                 this.boxes[i].previous.x1:= previous.y1
  139.                 this.boxes[i].previous.x2:= previous.y2
  140.                 this.boxes[i].previous.y1:= previous.x1
  141.                 this.boxes[i].previous.y2:= previous.x2
  142.                
  143.             }
  144.        
  145.            
  146.             x1 := this.back.size.x1 , x2 := this.back.size.x2 , y1 := this.back.size.y1 , y2 := this.back.size.y2
  147.             this.back.size:={x1:y1,x2:y2,y1:x1,y2:x2}
  148.            
  149.         }
  150.         else if(this.turnV = 3){
  151.             Loop % this.boxes.length() {
  152.                 i:=A_Index
  153.                 box:=this.boxes[i]
  154.                 box.x1-=this.back.size.x1
  155.                 box.x2-=this.back.size.x1
  156.                 box.previous.x1-=this.back.size.x1
  157.                 box.previous.x2-=this.back.size.x1
  158.             }
  159.             x1:=this.back.size.x1,x2:=this.back.size.x2,y1:=this.back.size.y1,y2:=this.back.size.y2
  160.             this.back.size:={x1:0,x2:x2-x1,y1:y1,y2:y2}
  161.             ;~ MsgBox,% this.back.size.x1
  162.             Loop % this.boxes.length() {
  163.                 i:=A_Index
  164.                 box:=this.boxes[i]
  165.                 box.x1:=this.back.size.x2 - box.x1
  166.                 box.x2:=this.back.size.x2 - box.x2
  167.                 temp1:=box.x1
  168.                 box.x1:=box.x2
  169.                 box.x2:=temp1
  170.                 box.previous.x1:=this.back.size.x2 -box.previous.x1
  171.                 box.previous.x2:=this.back.size.x2 -box.previous.x2
  172.                 temp1:=box.previous.x1
  173.                 box.previous.x1:=box.previous.x2
  174.                 box.previous.x2:=temp1
  175.             }
  176.         }
  177.         else if(this.turnV = 4){
  178.             ;   BLOCK 2
  179.             for i,value in this.boxes {
  180.                 ;~ MsgBox,%     this.backTemp.size.x2 - (   value.x1 - this.backTemp.size.x1)
  181.                 value:=value.clone()
  182.                 previous:=value.previous.clone()
  183.                 this.boxes[i].x1:=  value.y1
  184.                 this.boxes[i].x2:= value.y2
  185.                 this.boxes[i].y1:=  value.x1
  186.                 this.boxes[i].y2:= value.x2
  187.                
  188.                 this.boxes[i].previous.x1:= previous.y1
  189.                 this.boxes[i].previous.x2:= previous.y2
  190.                 this.boxes[i].previous.y1:= previous.x1
  191.                 this.boxes[i].previous.y2:= previous.x2
  192.                
  193.             }
  194.        
  195.            
  196.             x1 := this.back.size.x1 , x2 := this.back.size.x2 , y1 := this.back.size.y1 , y2 := this.back.size.y2
  197.             this.back.size:={x1:y1,x2:y2,y1:x1,y2:x2}
  198.             ;   the END of BLOCK 2
  199.             this.backtemp2:=this.back.clone()
  200.             ;   BLOCK 3
  201.             Loop % this.boxes.length() {
  202.                 i:=A_Index
  203.                 box:=this.boxes[i]
  204.                 box.x1-=this.back.size.x1
  205.                 box.x2-=this.back.size.x1
  206.                 box.previous.x1-=this.back.size.x1
  207.                 box.previous.x2-=this.back.size.x1
  208.             }
  209.             x1:=this.back.size.x1,x2:=this.back.size.x2,y1:=this.back.size.y1,y2:=this.back.size.y2
  210.             this.back.size:={x1:0,x2:x2-x1,y1:y1,y2:y2}
  211.             ;~ MsgBox,% this.back.size.x1
  212.             Loop % this.boxes.length() {
  213.                 i:=A_Index
  214.                 box:=this.boxes[i]
  215.                 box.x1:=this.back.size.x2 - box.x1
  216.                 box.x2:=this.back.size.x2 - box.x2
  217.                 temp1:=box.x1
  218.                 box.x1:=box.x2
  219.                 box.x2:=temp1
  220.                 box.previous.x1:=this.back.size.x2 -box.previous.x1
  221.                 box.previous.x2:=this.back.size.x2 -box.previous.x2
  222.                 temp1:=box.previous.x1
  223.                 box.previous.x1:=box.previous.x2
  224.                 box.previous.x2:=temp1
  225.             }
  226.             ;   the END of BLOCK3
  227.         }
  228.        
  229.        
  230.     }
  231.     turnBack(){
  232.    
  233.         if(this.turnV = 2){
  234.            
  235.            
  236.                 for i,value in this.boxes {
  237.                 ;~ MsgBox,%     this.backTemp.size.x2 - (   value.x1 - this.backTemp.size.x1)
  238.                 value:=value.clone()
  239.                
  240.                 this.boxes[i].x1:=  value.y1
  241.                 this.boxes[i].x2:= value.y2
  242.                 this.boxes[i].y1:=  value.x1
  243.                 this.boxes[i].y2:= value.x2
  244.                
  245.             }
  246.        
  247.            
  248.             x1 := this.back.size.x1 , x2 := this.back.size.x2 , y1 := this.back.size.y1 , y2 := this.back.size.y2
  249.             this.back.size:={x1:y1,x2:y2,y1:x1,y2:x2}
  250.            
  251.            
  252.            
  253.         }
  254.         else if(this.turnV = 3){
  255.        
  256.             Loop % this.boxes.length() {
  257.                 i:=A_Index
  258.                 box:=this.boxes[i]
  259.                 box.x1:=this.back.size.x2 - box.x1
  260.                 box.x2:=this.back.size.x2 - box.x2
  261.                 temp1:=box.x1
  262.                 box.x1:=box.x2
  263.                 box.x2:=temp1
  264.             }
  265.             x1 := this.backtemp.size.x1 , x2 := this.backtemp.size.x2 , y1 := this.backtemp.size.y1 , y2 := this.backtemp.size.y2
  266.             this.back.size:={x1:x1,x2:x2,y1:y1,y2:y2}
  267.             ;~ this.back:=this.backTemp
  268.             ;~ MsgBox,% this.back.size.x1
  269.             Loop % this.boxes.length() {
  270.                 i:=A_Index
  271.                 box:=this.boxes[i]
  272.                 box.x1+=this.back.size.x1
  273.                 box.x2+=this.back.size.x1
  274.                
  275.             }
  276.            
  277.         }
  278.         else if(this.turnV = 4){
  279.             Loop % this.boxes.length() {
  280.                 i:=A_Index
  281.                 box:=this.boxes[i]
  282.                 box.x1:=this.back.size.x2 - box.x1
  283.                 box.x2:=this.back.size.x2 - box.x2
  284.                 temp1:=box.x1
  285.                 box.x1:=box.x2
  286.                 box.x2:=temp1
  287.             }
  288.             x1 := this.backtemp2.size.x1 , x2 := this.backtemp2.size.x2 , y1 := this.backtemp2.size.y1 , y2 := this.backtemp2.size.y2
  289.             this.back.size:={x1:x1,x2:x2,y1:y1,y2:y2}
  290.             ;~ this.back:=this.backTemp
  291.             ;~ MsgBox,% this.back.size.x1
  292.             Loop % this.boxes.length() {
  293.                 i:=A_Index
  294.                 box:=this.boxes[i]
  295.                 box.x1+=this.back.size.x1
  296.                 box.x2+=this.back.size.x1
  297.                
  298.             }
  299.        
  300.         ;end of 3
  301.         ;beginning of 2
  302.         for i,value in this.boxes {
  303.                 ;~ MsgBox,%     this.backTemp.size.x2 - (   value.x1 - this.backTemp.size.x1)
  304.                 value:=value.clone()
  305.                
  306.                 this.boxes[i].x1:=  value.y1
  307.                 this.boxes[i].x2:= value.y2
  308.                 this.boxes[i].y1:=  value.x1
  309.                 this.boxes[i].y2:= value.x2
  310.                
  311.             }
  312.        
  313.            
  314.             x1 := this.back.size.x1 , x2 := this.back.size.x2 , y1 := this.back.size.y1 , y2 := this.back.size.y2
  315.             this.back.size:={x1:y1,x2:y2,y1:x1,y2:x2}
  316.        
  317.         }
  318.     }
  319.     setup(back){
  320.         this.boxes:=[]
  321.         this.back:=back
  322.         this.backTemp:=back
  323.         this.turnV:=0
  324.         this.nbox:=1
  325.         ;~ ToolTip,% back.size.x2 "<"
  326.     }
  327.     add(x1,y1,x2,y2,colour,blocked){
  328.         box:= new Box
  329.         box.set(x1,y1,x2,y2,colour,blocked)
  330.         this.boxes.Insert(box)
  331.  
  332.     }
  333.     draw(g){
  334.         for i,value in this.boxes
  335.             value.draw(g)
  336.     }
  337.     tocurrent(){
  338.         for i,value in this.boxes
  339.             value.tocurrent()
  340.     }
  341.     collapse(nbox){
  342.        
  343.        
  344.        
  345.         for i,value in this.boxes {
  346.             if(i == nbox)
  347.                 continue
  348.             if(this.myInterrupt(nbox,i)){
  349.                 if(this.boxes[i].blocked = 1){
  350.                     this.boxBorder(nbox,i)
  351.                 }
  352.                    
  353.    
  354.                 value.move((this.boxes[nbox].x2-value.x1 + 1),0)
  355.                
  356.                 this.collapse(i)
  357.                
  358.                
  359.             }
  360.         }
  361.         this.border(nbox)
  362.        
  363.     }
  364.     ;   205 206
  365.     boxBorder(nbox,i){
  366.         boxn:=this.boxes[nbox],boxi:=this.boxes[i]
  367.         border1:=boxn.x2 + 1 - boxi.x1
  368.         if(border1>this.borderV)
  369.             this.borderV:=border1
  370.     }
  371.     myInterrupt(nbox1,nbox2){
  372.         boxes:=this.boxes
  373.         box1:=boxes[nbox1], box2:=boxes[nbox2]
  374.         box1.getcentre(box1x3,box1y3),  box2.getcentre(box3x3,box2y3)
  375.         box1.getsize(w1,h1),    box2.getsize(w2,h2)
  376.         h:=(h1+h2)/2                                    ;   ,w:=(w2 + w1)/2
  377.             dy:=abs(box1y3 - box2y3)                    ;   ,dx:=abs(box1x3 - box2x3)\
  378.         if( dy <= h &&   box1.x2>=box2.x1   && box1.previous.x2 < box2.x1)
  379.             return 1
  380.         return 0
  381.     }
  382.     border(nbox){
  383.         box:=this.boxes[nbox],back:=this.back.size
  384.         ;~ ToolTip,% box.x2  " <>" back.x2
  385.         if(box.x2 >= back.x2){
  386.             border1:=box.x2 + 1 - back.x2
  387.             if(border1>this.borderV)
  388.                 this.borderV:=border1
  389.            
  390.         }
  391.    
  392.     }
  393.     automove(){
  394.         for i,value in this.boxes {
  395.            
  396.             IF(VALUE.PREVIOUS.X1 - VALUE.X1<> 0 )
  397.                 VALUE.MOVE(-THIS.MYmin(i),0)
  398.         }
  399.            
  400.     }
  401.     mymin(nbox){
  402.             ;~ if(this.turnv = 3)
  403.             ;~ MsgBox,% nbox " " this.boxes[3].x2
  404.         box:=this.boxes[nbox],borderv:=this.borderv
  405.         if(borderv <> 0)
  406.             min:=min(box.x1-box.previous.x1,Borderv)
  407.         else
  408.             min:=0
  409.        
  410.         return min
  411.     }
  412.     inside(){
  413.         MouseGetPos,x,y
  414.         for i,value in this.boxes {
  415.             if(value.inside(x,y) && GetKeyState("lbutton")){
  416.                 this.nbox:=i
  417.                 break
  418.             }
  419.         }
  420.        
  421.         for i,value in this.boxes {
  422.             if(value.inside(x,y) && GetKeyState("Q")){
  423.                 this.boxes[i].toggleblocked()
  424.            
  425.                 loop {
  426.                     if(GetKeyState("Q") = 0)
  427.                         break 2
  428.                 }
  429.             }
  430.         }
  431.     }
  432.    
  433.    
  434.    
  435.    
  436.    
  437.    
  438. }
  439.  
  440.  
  441.  
  442.  
  443.  class BackClass {
  444.     set(x1,y1,x2,y2,colour,colour2){
  445.         this.size:={x1:x1,x2:x2,y1:y1,y2:y2}
  446.         this.colour:=colour,this.colour2:=colour2
  447.         this.border:=0
  448.         ;~ ToolTip,% this.size.x2 "<"
  449.     }
  450.     draw(popup){
  451.         w:=popup.w,h:=popup.h,  g:=popup.g,colour:=this.colour,colour2:=this.colour2,   g:=popup.g
  452.         x1:=this.size.x1 ,y1:=this.size.y1,x2:=this.size.x2,y2:=this.size.y2
  453.         ;~ ToolTip,% this.size.x1
  454.         fill_boxx(g,colour2,0,0,w ,h)
  455.         fill_boxx(g,colour,0,0,x1 +1 ,h)
  456.         fill_boxx(g,colour,x2,0,w - x2  ,h)
  457.         fill_boxx(g,colour,0,0,w ,y1 + 1)
  458.         fill_boxx(g,colour,0,y2,w ,h - y2)
  459.     }
  460.  
  461. }
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  return
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  x::
  480.  Layered_Window_ShutDown(popUp)
  481.  ExitApp
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  ;STUFF  Hellbent HAS  added
  493. ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  494. ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  495. ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  496.  
  497. Layered_Window_SetUp(Smoothing,Window_X,Window_Y,Window_W,Window_H,Window_Name:=1,Window_Options:="")
  498.     {
  499.         Layered:={}
  500.         Layered.W:=Window_W
  501.         Layered.H:=Window_H
  502.         Layered.X:=Window_X
  503.         Layered.Y:=Window_Y
  504.         Layered.Name:=Window_Name
  505.         Layered.Options:=Window_Options
  506.         Layered.Token:=Gdip_Startup()
  507.         Create_Layered_GUI(Layered)
  508.         Layered.hwnd:=winExist()
  509.         Layered.hbm := CreateDIBSection(Window_W,Window_H)
  510.         Layered.hdc := CreateCompatibleDC()
  511.         Layered.obm := SelectObject(Layered.hdc,Layered.hbm)
  512.         Layered.G := Gdip_GraphicsFromHDC(Layered.hdc)
  513.         Gdip_SetSmoothingMode(Layered.G,Smoothing)
  514.         return Layered
  515.     }
  516.  
  517. Create_Layered_GUI(Layered)
  518.     {
  519.         Gui,% Layered.Name ": +E0x80000 +LastFound " Layered.Options
  520.         Gui,% Layered.Name ":Show",% "x" Layered.X " y" Layered.Y " w" Layered.W " h" Layered.H " NA"
  521.     }
  522.    
  523. Layered_Window_ShutDown(This)
  524.     {
  525.         SelectObject(This.hdc,This.obm)
  526.         DeleteObject(This.hbm)
  527.         DeleteDC(This.hdc)
  528.         gdip_deleteGraphics(This.g)
  529.         Gdip_Shutdown(This.Token)
  530.     }
  531.  
  532. Gdip_RotateBitmap(pBitmap, Angle, Dispose=1) { ; returns rotated bitmap. By Learning one.
  533. Gdip_GetImageDimensions(pBitmap, Width, Height)
  534. Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight)
  535. Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation)
  536.  
  537. pBitmap2 := Gdip_CreateBitmap(RWidth, RHeight)
  538. G2 := Gdip_GraphicsFromImage(pBitmap2), Gdip_SetSmoothingMode(G2, 4), Gdip_SetInterpolationMode(G2, 7)
  539. Gdip_TranslateWorldTransform(G2, xTranslation, yTranslation)
  540. Gdip_RotateWorldTransform(G2, Angle)
  541. Gdip_DrawImage(G2, pBitmap, 0, 0, Width, Height)
  542.  
  543. Gdip_ResetWorldTransform(G2)
  544. Gdip_DeleteGraphics(G2)
  545. if Dispose
  546. Gdip_DisposeImage(pBitmap)
  547. return pBitmap2
  548. }
  549.  
  550. New_Brush(colour:="000000",Alpha:="FF")
  551.     {
  552.         static Hellbent_Brush:=[]
  553.         new_colour := "0x" Alpha colour
  554.         Hellbent_Brush[Hellbent_Brush.Length()+1]:=Gdip_BrushCreateSolid(new_colour)
  555.         return Hellbent_Brush[Hellbent_Brush.Length()]
  556.     }
  557.    
  558.    
  559. New_Pen(colour:="000000",Alpha:="FF",Width:= 5)
  560.     {
  561.         static Hellbent_Pen:=[]
  562.         new_colour := "0x" Alpha colour
  563.         Hellbent_Pen[Hellbent_Pen.Length()+1]:=Gdip_CreatePen(New_Colour,Width)
  564.         return Hellbent_Pen[Hellbent_Pen.Length()]
  565.     }  
  566.    
  567. Fill_Box(pGraphics,pBrush,x,y,w,h) 
  568.     {
  569.         ;~ Gdip_FillRectangle(G, Brush, x, y, w, h)
  570.         Ptr := A_PtrSize ? "UPtr" : "UInt"
  571.    
  572.         return DllCall("gdiplus\GdipFillRectangle"
  573.                     , Ptr, pGraphics
  574.                     , Ptr, pBrush
  575.                     , "float", x
  576.                     , "float", y
  577.                     , "float", w
  578.                     , "float", h)
  579.     }
  580. Fill_Boxx(pGraphics,colour,x,y,w,h){
  581.     pBrush:=new_brush(colour)
  582. Fill_Box(pGraphics,pBrush,x,y,w,h) 
  583. }
  584. ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  585. ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  586. ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  587.  
  588. turn_bitmap(byref xbitmap,xturn){
  589. xWidth := Gdip_GetImageWidth(xbitmap)
  590. xHeight := Gdip_GetImageHeight(xbitmap)
  591.  
  592.  
  593. Gdip_GetRotatedDimensions(xWidth, xHeight, xturn, xRWidth, xRHeight)
  594. ;~ MsgBox,% "Rwidth: " RWidth "`nrheight: " rheight
  595.  
  596. ; xTranslation and yTranslation now contain the distance to shift the image by
  597. Gdip_GetRotatedTranslation(xWidth, xHeight, xturn, xxTranslation, xyTranslation)
  598. ;~ MsgBox,% "xTranslation: " xTranslation "`nyTranslation: " yTranslation
  599. xpBitmap := Gdip_CreateBitmap(xRWidth, xRHeight)                       ; Create a new bitmap
  600. xg := Gdip_GraphicsFromImage(xpBitmap)                                ; Get a pointer to the graphics of the bitmap
  601. Gdip_SetSmoothingMode(xg, 4)
  602.  
  603. Gdip_SetInterpolationMode(xg, 7)
  604. Gdip_TranslateWorldTransform(xg, xxTranslation, xyTranslation)
  605. Gdip_RotateWorldTransform(xg, xturn)
  606.  
  607.  
  608. Gdip_DrawImage(xg, xbitmap, 0,0, xWidth, xHeight)  
  609. Gdip_ResetWorldTransform(xg)
  610.  
  611. xbitmap:=xpbitmap
  612. }
  613.  
  614. turn_in_graphics(byref xg,xx,xy,xturn,xbitmap){
  615.    
  616.     turn_bitmap(xbitmap,xturn)
  617.     xWidth := Gdip_GetImageWidth(xbitmap)
  618. xHeight := Gdip_GetImageHeight(xbitmap)
  619.     Gdip_DrawImage(xG, xBitmap, xx-xWidth/2, xy-xheight/2, xWidth, xHeight)
  620.    
  621. }
  622. fill_ellipse(g,colour,x1,y1,w,h){
  623.         pBrush:=new_brush(colour)
  624.     Gdip_FillEllipse(g, pBrush, x1, y1, w, h)
  625.  
  626. }
  627.  
  628. sinG(x){
  629. return sin(x*3.14159265359/180)
  630. }
  631. cosG(x){
  632. return cos(x*3.14159265359/180)
  633. }
  634. /*
  635. two new functions and an opportunity to change
  636.  
  637. GDIP_SCALE(Map,SCALE)
  638. ; map you want to get a changed copy that is scale times less than
  639. original one
  640. fileScale(sFile,newName,SCALE)
  641. ;saves a changed( scale times less copy) of image from sfile Path
  642. to newname Path
  643. */
  644. GDIP_SCALE(Map,SCALE){
  645. Gdip_GetImageDimensions(MAP,  wOrig,  hOrig)
  646. newSize:={w:wOrig//SCALE,h:hOrig//SCALE}
  647.  
  648. newMap := Gdip_CreateBitmap(newSize.w, newSize.h)                    
  649. newMapG := Gdip_GraphicsFromImage(newMap)                              
  650. Gdip_SetSmoothingMode(newMapG, 4)
  651. Gdip_DrawImage(newMapG, map, 0, 0 ,newSize.w,newSize.h,0,0,wOrig,hOrig)
  652. return newMap
  653.    
  654.    
  655. }
  656.  
  657. fileScale(sFile,newName,SCALE){
  658.     map:=Gdip_CreateBitmapFromFile(sfile)
  659.     newmap:=GDIP_SCALE(Map,SCALE)
  660.     Gdip_SaveBitmapToFile(newmap, newname)
  661. }
  662.  
  663.  
  664.  
  665.         ;~ split(string){
  666.     ;~ string := StrSplit(string, A_Space)  
  667.     ;~ t:=1
  668.     ;~ while ( string.length() >= t) {
  669.         ;~ if(string[t]<>"")
  670.             ;~ t++
  671.         ;~ else
  672.             ;~ string.Remove(t)
  673.     ;~ }
  674.     ;~ return string
  675. ;~ }
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684. ; Gdip standard library v1.45 by tic (Tariq Porter) 07/09/11
  685. ; Modifed by Rseding91 using fincs 64 bit compatible Gdip library 5/1/2013
  686. ; Supports: Basic, _L ANSi, _L Unicode x86 and _L Unicode x64
  687. ;
  688. ; Updated 2/20/2014 - fixed Gdip_CreateRegion() and Gdip_GetClipRegion() on AHK Unicode x86
  689. ; Updated 5/13/2013 - fixed Gdip_SetBitmapToClipboard() on AHK Unicode x64
  690. ;
  691. ;#####################################################################################
  692. ;#####################################################################################
  693. ; STATUS ENUMERATION
  694. ; Return values for functions specified to have status enumerated return type
  695. ;#####################################################################################
  696. ;
  697. ; Ok =                      = 0
  698. ; GenericError              = 1
  699. ; InvalidParameter          = 2
  700. ; OutOfMemory               = 3
  701. ; ObjectBusy                = 4
  702. ; InsufficientBuffer        = 5
  703. ; NotImplemented            = 6
  704. ; Win32Error                = 7
  705. ; WrongState                = 8
  706. ; Aborted                   = 9
  707. ; FileNotFound              = 10
  708. ; ValueOverflow             = 11
  709. ; AccessDenied              = 12
  710. ; UnknownImageFormat        = 13
  711. ; FontFamilyNotFound        = 14
  712. ; FontStyleNotFound         = 15
  713. ; NotTrueTypeFont           = 16
  714. ; UnsupportedGdiplusVersion = 17
  715. ; GdiplusNotInitialized     = 18
  716. ; PropertyNotFound          = 19
  717. ; PropertyNotSupported      = 20
  718. ; ProfileNotFound           = 21
  719. ;
  720. ;#####################################################################################
  721. ;#####################################################################################
  722. ; FUNCTIONS
  723. ;#####################################################################################
  724. ;
  725. ; UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
  726. ; BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
  727. ; StretchBlt(dDC, dx, dy, dw, dh, sDC, sx, sy, sw, sh, Raster="")
  728. ; SetImage(hwnd, hBitmap)
  729. ; Gdip_BitmapFromScreen(Screen=0, Raster="")
  730. ; CreateRectF(ByRef RectF, x, y, w, h)
  731. ; CreateSizeF(ByRef SizeF, w, h)
  732. ; CreateDIBSection
  733. ;
  734. ;#####################################################################################
  735.  
  736. ; Function:                 UpdateLayeredWindow
  737. ; Description:              Updates a layered window with the handle to the DC of a gdi bitmap
  738. ;
  739. ; hwnd                      Handle of the layered window to update
  740. ; hdc                       Handle to the DC of the GDI bitmap to update the window with
  741. ; Layeredx                  x position to place the window
  742. ; Layeredy                  y position to place the window
  743. ; Layeredw                  Width of the window
  744. ; Layeredh                  Height of the window
  745. ; Alpha                     Default = 255 : The transparency (0-255) to set the window transparency
  746. ;
  747. ; return                    If the function succeeds, the return value is nonzero
  748. ;
  749. ; notes                     If x or y omitted, then layered window will use its current coordinates
  750. ;                           If w or h omitted then current width and height will be used
  751.  
  752. UpdateLayeredWindow(hwnd, hdc, x="", y="", w="", h="", Alpha=255)
  753. {
  754.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  755.    
  756.     if ((x != "") && (y != ""))
  757.         VarSetCapacity(pt, 8), NumPut(x, pt, 0, "UInt"), NumPut(y, pt, 4, "UInt")
  758.  
  759.     if (w = "") ||(h = "")
  760.         WinGetPos,,, w, h, ahk_id %hwnd%
  761.    
  762.     return DllCall("UpdateLayeredWindow"
  763.                     , Ptr, hwnd
  764.                     , Ptr, 0
  765.                     , Ptr, ((x = "") && (y = "")) ? 0 : &pt
  766.                     , "int64*", w|h<<32
  767.                     , Ptr, hdc
  768.                     , "int64*", 0
  769.                     , "uint", 0
  770.                     , "UInt*", Alpha<<16|1<<24
  771.                     , "uint", 2)
  772. }
  773.  
  774. ;#####################################################################################
  775.  
  776. ; Function              BitBlt
  777. ; Description           The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle
  778. ;                       of pixels from the specified source device context into a destination device context.
  779. ;
  780. ; dDC                   handle to destination DC
  781. ; dx                    x-coord of destination upper-left corner
  782. ; dy                    y-coord of destination upper-left corner
  783. ; dw                    width of the area to copy
  784. ; dh                    height of the area to copy
  785. ; sDC                   handle to source DC
  786. ; sx                    x-coordinate of source upper-left corner
  787. ; sy                    y-coordinate of source upper-left corner
  788. ; Raster                raster operation code
  789. ;
  790. ; return                If the function succeeds, the return value is nonzero
  791. ;
  792. ; notes                 If no raster operation is specified, then SRCCOPY is used, which copies the source directly to the destination rectangle
  793. ;
  794. ; BLACKNESS             = 0x00000042
  795. ; NOTSRCERASE           = 0x001100A6
  796. ; NOTSRCCOPY            = 0x00330008
  797. ; SRCERASE              = 0x00440328
  798. ; DSTINVERT             = 0x00550009
  799. ; PATINVERT             = 0x005A0049
  800. ; SRCINVERT             = 0x00660046
  801. ; SRCAND                = 0x008800C6
  802. ; MERGEPAINT            = 0x00BB0226
  803. ; MERGECOPY             = 0x00C000CA
  804. ; SRCCOPY               = 0x00CC0020
  805. ; SRCPAINT              = 0x00EE0086
  806. ; PATCOPY               = 0x00F00021
  807. ; PATPAINT              = 0x00FB0A09
  808. ; WHITENESS             = 0x00FF0062
  809. ; CAPTUREBLT            = 0x40000000
  810. ; NOMIRRORBITMAP        = 0x80000000
  811.  
  812. BitBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, Raster="")
  813. {
  814.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  815.    
  816.     return DllCall("gdi32\BitBlt"
  817.                     , Ptr, dDC
  818.                     , "int", dx
  819.                     , "int", dy
  820.                     , "int", dw
  821.                     , "int", dh
  822.                     , Ptr, sDC
  823.                     , "int", sx
  824.                     , "int", sy
  825.                     , "uint", Raster ? Raster : 0x00CC0020)
  826. }
  827.  
  828. ;#####################################################################################
  829.  
  830. ; Function              StretchBlt
  831. ; Description           The StretchBlt function copies a bitmap from a source rectangle into a destination rectangle,
  832. ;                       stretching or compressing the bitmap to fit the dimensions of the destination rectangle, if necessary.
  833. ;                       The system stretches or compresses the bitmap according to the stretching mode currently set in the destination device context.
  834. ;
  835. ; ddc                   handle to destination DC
  836. ; dx                    x-coord of destination upper-left corner
  837. ; dy                    y-coord of destination upper-left corner
  838. ; dw                    width of destination rectangle
  839. ; dh                    height of destination rectangle
  840. ; sdc                   handle to source DC
  841. ; sx                    x-coordinate of source upper-left corner
  842. ; sy                    y-coordinate of source upper-left corner
  843. ; sw                    width of source rectangle
  844. ; sh                    height of source rectangle
  845. ; Raster                raster operation code
  846. ;
  847. ; return                If the function succeeds, the return value is nonzero
  848. ;
  849. ; notes                 If no raster operation is specified, then SRCCOPY is used. It uses the same raster operations as BitBlt    
  850.  
  851. StretchBlt(ddc, dx, dy, dw, dh, sdc, sx, sy, sw, sh, Raster="")
  852. {
  853.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  854.    
  855.     return DllCall("gdi32\StretchBlt"
  856.                     , Ptr, ddc
  857.                     , "int", dx
  858.                     , "int", dy
  859.                     , "int", dw
  860.                     , "int", dh
  861.                     , Ptr, sdc
  862.                     , "int", sx
  863.                     , "int", sy
  864.                     , "int", sw
  865.                     , "int", sh
  866.                     , "uint", Raster ? Raster : 0x00CC0020)
  867. }
  868.  
  869. ;#####################################################################################
  870.  
  871. ; Function              SetStretchBltMode
  872. ; Description           The SetStretchBltMode function sets the bitmap stretching mode in the specified device context
  873. ;
  874. ; hdc                   handle to the DC
  875. ; iStretchMode          The stretching mode, describing how the target will be stretched
  876. ;
  877. ; return                If the function succeeds, the return value is the previous stretching mode. If it fails it will return 0
  878. ;
  879. ; STRETCH_ANDSCANS      = 0x01
  880. ; STRETCH_ORSCANS       = 0x02
  881. ; STRETCH_DELETESCANS   = 0x03
  882. ; STRETCH_HALFTONE      = 0x04
  883.  
  884. SetStretchBltMode(hdc, iStretchMode=4)
  885. {
  886.     return DllCall("gdi32\SetStretchBltMode"
  887.                     , A_PtrSize ? "UPtr" : "UInt", hdc
  888.                     , "int", iStretchMode)
  889. }
  890.  
  891. ;#####################################################################################
  892.  
  893. ; Function              SetImage
  894. ; Description           Associates a new image with a static control
  895. ;
  896. ; hwnd                  handle of the control to update
  897. ; hBitmap               a gdi bitmap to associate the static control with
  898. ;
  899. ; return                If the function succeeds, the return value is nonzero
  900.  
  901. SetImage(hwnd, hBitmap)
  902. {
  903.     SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
  904.     E := ErrorLevel
  905.     DeleteObject(E)
  906.     return E
  907. }
  908.  
  909. ;#####################################################################################
  910.  
  911. ; Function              SetSysColorToControl
  912. ; Description           Sets a solid colour to a control
  913. ;
  914. ; hwnd                  handle of the control to update
  915. ; SysColor              A system colour to set to the control
  916. ;
  917. ; return                If the function succeeds, the return value is zero
  918. ;
  919. ; notes                 A control must have the 0xE style set to it so it is recognised as a bitmap
  920. ;                       By default SysColor=15 is used which is COLOR_3DFACE. This is the standard background for a control
  921. ;
  922. ; COLOR_3DDKSHADOW              = 21
  923. ; COLOR_3DFACE                  = 15
  924. ; COLOR_3DHIGHLIGHT             = 20
  925. ; COLOR_3DHILIGHT               = 20
  926. ; COLOR_3DLIGHT                 = 22
  927. ; COLOR_3DSHADOW                = 16
  928. ; COLOR_ACTIVEBORDER            = 10
  929. ; COLOR_ACTIVECAPTION           = 2
  930. ; COLOR_APPWORKSPACE            = 12
  931. ; COLOR_BACKGROUND              = 1
  932. ; COLOR_BTNFACE                 = 15
  933. ; COLOR_BTNHIGHLIGHT            = 20
  934. ; COLOR_BTNHILIGHT              = 20
  935. ; COLOR_BTNSHADOW               = 16
  936. ; COLOR_BTNTEXT                 = 18
  937. ; COLOR_CAPTIONTEXT             = 9
  938. ; COLOR_DESKTOP                 = 1
  939. ; COLOR_GRADIENTACTIVECAPTION   = 27
  940. ; COLOR_GRADIENTINACTIVECAPTION = 28
  941. ; COLOR_GRAYTEXT                = 17
  942. ; COLOR_HIGHLIGHT               = 13
  943. ; COLOR_HIGHLIGHTTEXT           = 14
  944. ; COLOR_HOTLIGHT                = 26
  945. ; COLOR_INACTIVEBORDER          = 11
  946. ; COLOR_INACTIVECAPTION         = 3
  947. ; COLOR_INACTIVECAPTIONTEXT     = 19
  948. ; COLOR_INFOBK                  = 24
  949. ; COLOR_INFOTEXT                = 23
  950. ; COLOR_MENU                    = 4
  951. ; COLOR_MENUHILIGHT             = 29
  952. ; COLOR_MENUBAR                 = 30
  953. ; COLOR_MENUTEXT                = 7
  954. ; COLOR_SCROLLBAR               = 0
  955. ; COLOR_WINDOW                  = 5
  956. ; COLOR_WINDOWFRAME             = 6
  957. ; COLOR_WINDOWTEXT              = 8
  958.  
  959. SetSysColorToControl(hwnd, SysColor=15)
  960. {
  961.    WinGetPos,,, w, h, ahk_id %hwnd%
  962.    bc := DllCall("GetSysColor", "Int", SysColor, "UInt")
  963.    pBrushClear := Gdip_BrushCreateSolid(0xff000000 | (bc >> 16 | bc & 0xff00 | (bc & 0xff) << 16))
  964.    pBitmap := Gdip_CreateBitmap(w, h), G := Gdip_GraphicsFromImage(pBitmap)
  965.    Gdip_FillRectangle(G, pBrushClear, 0, 0, w, h)
  966.    hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
  967.    SetImage(hwnd, hBitmap)
  968.    Gdip_DeleteBrush(pBrushClear)
  969.    Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmap), DeleteObject(hBitmap)
  970.    return 0
  971. }
  972.  
  973. ;#####################################################################################
  974.  
  975. ; Function              Gdip_BitmapFromScreen
  976. ; Description           Gets a gdi+ bitmap from the screen
  977. ;
  978. ; Screen                0 = All screens
  979. ;                       Any numerical value = Just that screen
  980. ;                       x|y|w|h = Take specific coordinates with a width and height
  981. ; Raster                raster operation code
  982. ;
  983. ; return                If the function succeeds, the return value is a pointer to a gdi+ bitmap
  984. ;                       -1:     one or more of x,y,w,h not passed properly
  985. ;
  986. ; notes                 If no raster operation is specified, then SRCCOPY is used to the returned bitmap
  987.  
  988. Gdip_BitmapFromScreen(Screen=0, Raster="")
  989. {
  990.     if (Screen = 0)
  991.     {
  992.         Sysget, x, 76
  993.         Sysget, y, 77  
  994.         Sysget, w, 78
  995.         Sysget, h, 79
  996.     }
  997.     else if (SubStr(Screen, 1, 5) = "hwnd:")
  998.     {
  999.         Screen := SubStr(Screen, 6)
  1000.         if !WinExist( "ahk_id " Screen)
  1001.             return -2
  1002.         WinGetPos,,, w, h, ahk_id %Screen%
  1003.         x := y := 0
  1004.         hhdc := GetDCEx(Screen, 3)
  1005.     }
  1006.     else if (Screen&1 != "")
  1007.     {
  1008.         Sysget, M, Monitor, %Screen%
  1009.         x := MLeft, y := MTop, w := MRight-MLeft, h := MBottom-MTop
  1010.     }
  1011.     else
  1012.     {
  1013.         StringSplit, S, Screen, |
  1014.         x := S1, y := S2, w := S3, h := S4
  1015.     }
  1016.  
  1017.     if (x = "") || (y = "") || (w = "") || (h = "")
  1018.         return -1
  1019.  
  1020.     chdc := CreateCompatibleDC(), hbm := CreateDIBSection(w, h, chdc), obm := SelectObject(chdc, hbm), hhdc := hhdc ? hhdc : GetDC()
  1021.     BitBlt(chdc, 0, 0, w, h, hhdc, x, y, Raster)
  1022.     ReleaseDC(hhdc)
  1023.    
  1024.     pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
  1025.     SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(hhdc), DeleteDC(chdc)
  1026.     return pBitmap
  1027. }
  1028.  
  1029. ;#####################################################################################
  1030.  
  1031. ; Function              Gdip_BitmapFromHWND
  1032. ; Description           Uses PrintWindow to get a handle to the specified window and return a bitmap from it
  1033. ;
  1034. ; hwnd                  handle to the window to get a bitmap from
  1035. ;
  1036. ; return                If the function succeeds, the return value is a pointer to a gdi+ bitmap
  1037. ;
  1038. ; notes                 Window must not be not minimised in order to get a handle to it's client area
  1039.  
  1040. Gdip_BitmapFromHWND(hwnd)
  1041. {
  1042.     WinGetPos,,, Width, Height, ahk_id %hwnd%
  1043.     hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
  1044.     PrintWindow(hwnd, hdc)
  1045.     pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
  1046.     SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
  1047.     return pBitmap
  1048. }
  1049.  
  1050. ;#####################################################################################
  1051.  
  1052. ; Function              CreateRectF
  1053. ; Description           Creates a RectF object, containing a the coordinates and dimensions of a rectangle
  1054. ;
  1055. ; RectF                 Name to call the RectF object
  1056. ; x                     x-coordinate of the upper left corner of the rectangle
  1057. ; y                     y-coordinate of the upper left corner of the rectangle
  1058. ; w                     Width of the rectangle
  1059. ; h                     Height of the rectangle
  1060. ;
  1061. ; return                No return value
  1062.  
  1063. CreateRectF(ByRef RectF, x, y, w, h)
  1064. {
  1065.    VarSetCapacity(RectF, 16)
  1066.    NumPut(x, RectF, 0, "float"), NumPut(y, RectF, 4, "float"), NumPut(w, RectF, 8, "float"), NumPut(h, RectF, 12, "float")
  1067. }
  1068.  
  1069. ;#####################################################################################
  1070.  
  1071. ; Function              CreateRect
  1072. ; Description           Creates a Rect object, containing a the coordinates and dimensions of a rectangle
  1073. ;
  1074. ; RectF                 Name to call the RectF object
  1075. ; x                     x-coordinate of the upper left corner of the rectangle
  1076. ; y                     y-coordinate of the upper left corner of the rectangle
  1077. ; w                     Width of the rectangle
  1078. ; h                     Height of the rectangle
  1079. ;
  1080. ; return                No return value
  1081.  
  1082. CreateRect(ByRef Rect, x, y, w, h)
  1083. {
  1084.     VarSetCapacity(Rect, 16)
  1085.     NumPut(x, Rect, 0, "uint"), NumPut(y, Rect, 4, "uint"), NumPut(w, Rect, 8, "uint"), NumPut(h, Rect, 12, "uint")
  1086. }
  1087. ;#####################################################################################
  1088.  
  1089. ; Function              CreateSizeF
  1090. ; Description           Creates a SizeF object, containing an 2 values
  1091. ;
  1092. ; SizeF                 Name to call the SizeF object
  1093. ; w                     w-value for the SizeF object
  1094. ; h                     h-value for the SizeF object
  1095. ;
  1096. ; return                No Return value
  1097.  
  1098. CreateSizeF(ByRef SizeF, w, h)
  1099. {
  1100.    VarSetCapacity(SizeF, 8)
  1101.    NumPut(w, SizeF, 0, "float"), NumPut(h, SizeF, 4, "float")    
  1102. }
  1103. ;#####################################################################################
  1104.  
  1105. ; Function              CreatePointF
  1106. ; Description           Creates a SizeF object, containing an 2 values
  1107. ;
  1108. ; SizeF                 Name to call the SizeF object
  1109. ; w                     w-value for the SizeF object
  1110. ; h                     h-value for the SizeF object
  1111. ;
  1112. ; return                No Return value
  1113.  
  1114. CreatePointF(ByRef PointF, x, y)
  1115. {
  1116.    VarSetCapacity(PointF, 8)
  1117.    NumPut(x, PointF, 0, "float"), NumPut(y, PointF, 4, "float")    
  1118. }
  1119. ;#####################################################################################
  1120.  
  1121. ; Function              CreateDIBSection
  1122. ; Description           The CreateDIBSection function creates a DIB (Device Independent Bitmap) that applications can write to directly
  1123. ;
  1124. ; w                     width of the bitmap to create
  1125. ; h                     height of the bitmap to create
  1126. ; hdc                   a handle to the device context to use the palette from
  1127. ; bpp                   bits per pixel (32 = ARGB)
  1128. ; ppvBits               A pointer to a variable that receives a pointer to the location of the DIB bit values
  1129. ;
  1130. ; return                returns a DIB. A gdi bitmap
  1131. ;
  1132. ; notes                 ppvBits will receive the location of the pixels in the DIB
  1133.  
  1134. CreateDIBSection(w, h, hdc="", bpp=32, ByRef ppvBits=0)
  1135. {
  1136.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1137.    
  1138.     hdc2 := hdc ? hdc : GetDC()
  1139.     VarSetCapacity(bi, 40, 0)
  1140.    
  1141.     NumPut(w, bi, 4, "uint")
  1142.     , NumPut(h, bi, 8, "uint")
  1143.     , NumPut(40, bi, 0, "uint")
  1144.     , NumPut(1, bi, 12, "ushort")
  1145.     , NumPut(0, bi, 16, "uInt")
  1146.     , NumPut(bpp, bi, 14, "ushort")
  1147.    
  1148.     hbm := DllCall("CreateDIBSection"
  1149.                     , Ptr, hdc2
  1150.                     , Ptr, &bi
  1151.                     , "uint", 0
  1152.                     , A_PtrSize ? "UPtr*" : "uint*", ppvBits
  1153.                     , Ptr, 0
  1154.                     , "uint", 0, Ptr)
  1155.  
  1156.     if !hdc
  1157.         ReleaseDC(hdc2)
  1158.     return hbm
  1159. }
  1160.  
  1161. ;#####################################################################################
  1162.  
  1163. ; Function              PrintWindow
  1164. ; Description           The PrintWindow function copies a visual window into the specified device context (DC), typically a printer DC
  1165. ;
  1166. ; hwnd                  A handle to the window that will be copied
  1167. ; hdc                   A handle to the device context
  1168. ; Flags                 Drawing options
  1169. ;
  1170. ; return                If the function succeeds, it returns a nonzero value
  1171. ;
  1172. ; PW_CLIENTONLY         = 1
  1173.  
  1174. PrintWindow(hwnd, hdc, Flags=0)
  1175. {
  1176.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1177.    
  1178.     return DllCall("PrintWindow", Ptr, hwnd, Ptr, hdc, "uint", Flags)
  1179. }
  1180.  
  1181. ;#####################################################################################
  1182.  
  1183. ; Function              DestroyIcon
  1184. ; Description           Destroys an icon and frees any memory the icon occupied
  1185. ;
  1186. ; hIcon                 Handle to the icon to be destroyed. The icon must not be in use
  1187. ;
  1188. ; return                If the function succeeds, the return value is nonzero
  1189.  
  1190. DestroyIcon(hIcon)
  1191. {
  1192.     return DllCall("DestroyIcon", A_PtrSize ? "UPtr" : "UInt", hIcon)
  1193. }
  1194.  
  1195. ;#####################################################################################
  1196.  
  1197. PaintDesktop(hdc)
  1198. {
  1199.     return DllCall("PaintDesktop", A_PtrSize ? "UPtr" : "UInt", hdc)
  1200. }
  1201.  
  1202. ;#####################################################################################
  1203.  
  1204. CreateCompatibleBitmap(hdc, w, h)
  1205. {
  1206.     return DllCall("gdi32\CreateCompatibleBitmap", A_PtrSize ? "UPtr" : "UInt", hdc, "int", w, "int", h)
  1207. }
  1208.  
  1209. ;#####################################################################################
  1210.  
  1211. ; Function              CreateCompatibleDC
  1212. ; Description           This function creates a memory device context (DC) compatible with the specified device
  1213. ;
  1214. ; hdc                   Handle to an existing device context                   
  1215. ;
  1216. ; return                returns the handle to a device context or 0 on failure
  1217. ;
  1218. ; notes                 If this handle is 0 (by default), the function creates a memory device context compatible with the application's current screen
  1219.  
  1220. CreateCompatibleDC(hdc=0)
  1221. {
  1222.    return DllCall("CreateCompatibleDC", A_PtrSize ? "UPtr" : "UInt", hdc)
  1223. }
  1224.  
  1225. ;#####################################################################################
  1226.  
  1227. ; Function              SelectObject
  1228. ; Description           The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type
  1229. ;
  1230. ; hdc                   Handle to a DC
  1231. ; hgdiobj               A handle to the object to be selected into the DC
  1232. ;
  1233. ; return                If the selected object is not a region and the function succeeds, the return value is a handle to the object being replaced
  1234. ;
  1235. ; notes                 The specified object must have been created by using one of the following functions
  1236. ;                       Bitmap - CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection (A single bitmap cannot be selected into more than one DC at the same time)
  1237. ;                       Brush - CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
  1238. ;                       Font - CreateFont, CreateFontIndirect
  1239. ;                       Pen - CreatePen, CreatePenIndirect
  1240. ;                       Region - CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirect
  1241. ;
  1242. ; notes                 If the selected object is a region and the function succeeds, the return value is one of the following value
  1243. ;
  1244. ; SIMPLEREGION          = 2 Region consists of a single rectangle
  1245. ; COMPLEXREGION         = 3 Region consists of more than one rectangle
  1246. ; NULLREGION            = 1 Region is empty
  1247.  
  1248. SelectObject(hdc, hgdiobj)
  1249. {
  1250.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1251.    
  1252.     return DllCall("SelectObject", Ptr, hdc, Ptr, hgdiobj)
  1253. }
  1254.  
  1255. ;#####################################################################################
  1256.  
  1257. ; Function              DeleteObject
  1258. ; Description           This function deletes a logical pen, brush, font, bitmap, region, or palette, freeing all system resources associated with the object
  1259. ;                       After the object is deleted, the specified handle is no longer valid
  1260. ;
  1261. ; hObject               Handle to a logical pen, brush, font, bitmap, region, or palette to delete
  1262. ;
  1263. ; return                Nonzero indicates success. Zero indicates that the specified handle is not valid or that the handle is currently selected into a device context
  1264.  
  1265. DeleteObject(hObject)
  1266. {
  1267.    return DllCall("DeleteObject", A_PtrSize ? "UPtr" : "UInt", hObject)
  1268. }
  1269.  
  1270. ;#####################################################################################
  1271.  
  1272. ; Function              GetDC
  1273. ; Description           This function retrieves a handle to a display device context (DC) for the client area of the specified window.
  1274. ;                       The display device context can be used in subsequent graphics display interface (GDI) functions to draw in the client area of the window.
  1275. ;
  1276. ; hwnd                  Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen                  
  1277. ;
  1278. ; return                The handle the device context for the specified window's client area indicates success. NULL indicates failure
  1279.  
  1280. GetDC(hwnd=0)
  1281. {
  1282.     return DllCall("GetDC", A_PtrSize ? "UPtr" : "UInt", hwnd)
  1283. }
  1284.  
  1285. ;#####################################################################################
  1286.  
  1287. ; DCX_CACHE = 0x2
  1288. ; DCX_CLIPCHILDREN = 0x8
  1289. ; DCX_CLIPSIBLINGS = 0x10
  1290. ; DCX_EXCLUDERGN = 0x40
  1291. ; DCX_EXCLUDEUPDATE = 0x100
  1292. ; DCX_INTERSECTRGN = 0x80
  1293. ; DCX_INTERSECTUPDATE = 0x200
  1294. ; DCX_LOCKWINDOWUPDATE = 0x400
  1295. ; DCX_NORECOMPUTE = 0x100000
  1296. ; DCX_NORESETATTRS = 0x4
  1297. ; DCX_PARENTCLIP = 0x20
  1298. ; DCX_VALIDATE = 0x200000
  1299. ; DCX_WINDOW = 0x1
  1300.  
  1301. GetDCEx(hwnd, flags=0, hrgnClip=0)
  1302. {
  1303.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1304.    
  1305.     return DllCall("GetDCEx", Ptr, hwnd, Ptr, hrgnClip, "int", flags)
  1306. }
  1307.  
  1308. ;#####################################################################################
  1309.  
  1310. ; Function              ReleaseDC
  1311. ; Description           This function releases a device context (DC), freeing it for use by other applications. The effect of ReleaseDC depends on the type of device context
  1312. ;
  1313. ; hdc                   Handle to the device context to be released
  1314. ; hwnd                  Handle to the window whose device context is to be released
  1315. ;
  1316. ; return                1 = released
  1317. ;                       0 = not released
  1318. ;
  1319. ; notes                 The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common device context
  1320. ;                       An application cannot use the ReleaseDC function to release a device context that was created by calling the CreateDC function; instead, it must use the DeleteDC function.
  1321.  
  1322. ReleaseDC(hdc, hwnd=0)
  1323. {
  1324.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1325.    
  1326.     return DllCall("ReleaseDC", Ptr, hwnd, Ptr, hdc)
  1327. }
  1328.  
  1329. ;#####################################################################################
  1330.  
  1331. ; Function              DeleteDC
  1332. ; Description           The DeleteDC function deletes the specified device context (DC)
  1333. ;
  1334. ; hdc                   A handle to the device context
  1335. ;
  1336. ; return                If the function succeeds, the return value is nonzero
  1337. ;
  1338. ; notes                 An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC
  1339.  
  1340. DeleteDC(hdc)
  1341. {
  1342.    return DllCall("DeleteDC", A_PtrSize ? "UPtr" : "UInt", hdc)
  1343. }
  1344. ;#####################################################################################
  1345.  
  1346. ; Function              Gdip_LibraryVersion
  1347. ; Description           Get the current library version
  1348. ;
  1349. ; return                the library version
  1350. ;
  1351. ; notes                 This is useful for non compiled programs to ensure that a person doesn't run an old version when testing your scripts
  1352.  
  1353. Gdip_LibraryVersion()
  1354. {
  1355.     return 1.45
  1356. }
  1357.  
  1358. ;#####################################################################################
  1359.  
  1360. ; Function              Gdip_LibrarySubVersion
  1361. ; Description           Get the current library sub version
  1362. ;
  1363. ; return                the library sub version
  1364. ;
  1365. ; notes                 This is the sub-version currently maintained by Rseding91
  1366. Gdip_LibrarySubVersion()
  1367. {
  1368.     return 1.47
  1369. }
  1370.  
  1371. ;#####################################################################################
  1372.  
  1373. ; Function:             Gdip_BitmapFromBRA
  1374. ; Description:          Gets a pointer to a gdi+ bitmap from a BRA file
  1375. ;
  1376. ; BRAFromMemIn          The variable for a BRA file read to memory
  1377. ; File                  The name of the file, or its number that you would like (This depends on alternate parameter)
  1378. ; Alternate             Changes whether the File parameter is the file name or its number
  1379. ;
  1380. ; return                If the function succeeds, the return value is a pointer to a gdi+ bitmap
  1381. ;                       -1 = The BRA variable is empty
  1382. ;                       -2 = The BRA has an incorrect header
  1383. ;                       -3 = The BRA has information missing
  1384. ;                       -4 = Could not find file inside the BRA
  1385.  
  1386. Gdip_BitmapFromBRA(ByRef BRAFromMemIn, File, Alternate=0)
  1387. {
  1388.     Static FName = "ObjRelease"
  1389.    
  1390.     if !BRAFromMemIn
  1391.         return -1
  1392.     Loop, Parse, BRAFromMemIn, `n
  1393.     {
  1394.         if (A_Index = 1)
  1395.         {
  1396.             StringSplit, Header, A_LoopField, |
  1397.             if (Header0 != 4 || Header2 != "BRA!")
  1398.                 return -2
  1399.         }
  1400.         else if (A_Index = 2)
  1401.         {
  1402.             StringSplit, Info, A_LoopField, |
  1403.             if (Info0 != 3)
  1404.                 return -3
  1405.         }
  1406.         else
  1407.             break
  1408.     }
  1409.     if !Alternate
  1410.         StringReplace, File, File, \, \\, All
  1411.     RegExMatch(BRAFromMemIn, "mi`n)^" (Alternate ? File "\|.+?\|(\d+)\|(\d+)" : "\d+\|" File "\|(\d+)\|(\d+)") "$", FileInfo)
  1412.     if !FileInfo
  1413.         return -4
  1414.    
  1415.     hData := DllCall("GlobalAlloc", "uint", 2, Ptr, FileInfo2, Ptr)
  1416.     pData := DllCall("GlobalLock", Ptr, hData, Ptr)
  1417.     DllCall("RtlMoveMemory", Ptr, pData, Ptr, &BRAFromMemIn+Info2+FileInfo1, Ptr, FileInfo2)
  1418.     DllCall("GlobalUnlock", Ptr, hData)
  1419.     DllCall("ole32\CreateStreamOnHGlobal", Ptr, hData, "int", 1, A_PtrSize ? "UPtr*" : "UInt*", pStream)
  1420.     DllCall("gdiplus\GdipCreateBitmapFromStream", Ptr, pStream, A_PtrSize ? "UPtr*" : "UInt*", pBitmap)
  1421.     If (A_PtrSize)
  1422.         %FName%(pStream)
  1423.     Else
  1424.         DllCall(NumGet(NumGet(1*pStream)+8), "uint", pStream)
  1425.     return pBitmap
  1426. }
  1427.  
  1428. ;#####################################################################################
  1429.  
  1430. ; Function              Gdip_DrawRectangle
  1431. ; Description           This function uses a pen to draw the outline of a rectangle into the Graphics of a bitmap
  1432. ;
  1433. ; pGraphics             Pointer to the Graphics of a bitmap
  1434. ; pPen                  Pointer to a pen
  1435. ; x                     x-coordinate of the top left of the rectangle
  1436. ; y                     y-coordinate of the top left of the rectangle
  1437. ; w                     width of the rectanlge
  1438. ; h                     height of the rectangle
  1439. ;
  1440. ; return                status enumeration. 0 = success
  1441. ;
  1442. ; notes                 as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
  1443.  
  1444. Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
  1445. {
  1446.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1447.    
  1448.     return DllCall("gdiplus\GdipDrawRectangle", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
  1449. }
  1450.  
  1451. ;#####################################################################################
  1452.  
  1453. ; Function              Gdip_DrawRoundedRectangle
  1454. ; Description           This function uses a pen to draw the outline of a rounded rectangle into the Graphics of a bitmap
  1455. ;
  1456. ; pGraphics             Pointer to the Graphics of a bitmap
  1457. ; pPen                  Pointer to a pen
  1458. ; x                     x-coordinate of the top left of the rounded rectangle
  1459. ; y                     y-coordinate of the top left of the rounded rectangle
  1460. ; w                     width of the rectanlge
  1461. ; h                     height of the rectangle
  1462. ; r                     radius of the rounded corners
  1463. ;
  1464. ; return                status enumeration. 0 = success
  1465. ;
  1466. ; notes                 as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
  1467.  
  1468. Gdip_DrawRoundedRectangle(pGraphics, pPen, x, y, w, h, r)
  1469. {
  1470.     Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
  1471.     Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
  1472.     Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
  1473.     Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
  1474.     E := Gdip_DrawRectangle(pGraphics, pPen, x, y, w, h)
  1475.     Gdip_ResetClip(pGraphics)
  1476.     Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
  1477.     Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
  1478.     Gdip_DrawEllipse(pGraphics, pPen, x, y, 2*r, 2*r)
  1479.     Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y, 2*r, 2*r)
  1480.     Gdip_DrawEllipse(pGraphics, pPen, x, y+h-(2*r), 2*r, 2*r)
  1481.     Gdip_DrawEllipse(pGraphics, pPen, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
  1482.     Gdip_ResetClip(pGraphics)
  1483.     return E
  1484. }
  1485.  
  1486. ;#####################################################################################
  1487.  
  1488. ; Function              Gdip_DrawEllipse
  1489. ; Description           This function uses a pen to draw the outline of an ellipse into the Graphics of a bitmap
  1490. ;
  1491. ; pGraphics             Pointer to the Graphics of a bitmap
  1492. ; pPen                  Pointer to a pen
  1493. ; x                     x-coordinate of the top left of the rectangle the ellipse will be drawn into
  1494. ; y                     y-coordinate of the top left of the rectangle the ellipse will be drawn into
  1495. ; w                     width of the ellipse
  1496. ; h                     height of the ellipse
  1497. ;
  1498. ; return                status enumeration. 0 = success
  1499. ;
  1500. ; notes                 as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
  1501.  
  1502. Gdip_DrawEllipse(pGraphics, pPen, x, y, w, h)
  1503. {
  1504.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1505.    
  1506.     return DllCall("gdiplus\GdipDrawEllipse", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h)
  1507. }
  1508.  
  1509. ;#####################################################################################
  1510.  
  1511. ; Function              Gdip_DrawBezier
  1512. ; Description           This function uses a pen to draw the outline of a bezier (a weighted curve) into the Graphics of a bitmap
  1513. ;
  1514. ; pGraphics             Pointer to the Graphics of a bitmap
  1515. ; pPen                  Pointer to a pen
  1516. ; x1                    x-coordinate of the start of the bezier
  1517. ; y1                    y-coordinate of the start of the bezier
  1518. ; x2                    x-coordinate of the first arc of the bezier
  1519. ; y2                    y-coordinate of the first arc of the bezier
  1520. ; x3                    x-coordinate of the second arc of the bezier
  1521. ; y3                    y-coordinate of the second arc of the bezier
  1522. ; x4                    x-coordinate of the end of the bezier
  1523. ; y4                    y-coordinate of the end of the bezier
  1524. ;
  1525. ; return                status enumeration. 0 = success
  1526. ;
  1527. ; notes                 as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
  1528.  
  1529. Gdip_DrawBezier(pGraphics, pPen, x1, y1, x2, y2, x3, y3, x4, y4)
  1530. {
  1531.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1532.    
  1533.     return DllCall("gdiplus\GdipDrawBezier"
  1534.                     , Ptr, pgraphics
  1535.                     , Ptr, pPen
  1536.                     , "float", x1
  1537.                     , "float", y1
  1538.                     , "float", x2
  1539.                     , "float", y2
  1540.                     , "float", x3
  1541.                     , "float", y3
  1542.                     , "float", x4
  1543.                     , "float", y4)
  1544. }
  1545.  
  1546. ;#####################################################################################
  1547.  
  1548. ; Function              Gdip_DrawArc
  1549. ; Description           This function uses a pen to draw the outline of an arc into the Graphics of a bitmap
  1550. ;
  1551. ; pGraphics             Pointer to the Graphics of a bitmap
  1552. ; pPen                  Pointer to a pen
  1553. ; x                     x-coordinate of the start of the arc
  1554. ; y                     y-coordinate of the start of the arc
  1555. ; w                     width of the arc
  1556. ; h                     height of the arc
  1557. ; StartAngle            specifies the angle between the x-axis and the starting point of the arc
  1558. ; SweepAngle            specifies the angle between the starting and ending points of the arc
  1559. ;
  1560. ; return                status enumeration. 0 = success
  1561. ;
  1562. ; notes                 as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
  1563.  
  1564. Gdip_DrawArc(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
  1565. {
  1566.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1567.    
  1568.     return DllCall("gdiplus\GdipDrawArc"
  1569.                     , Ptr, pGraphics
  1570.                     , Ptr, pPen
  1571.                     , "float", x
  1572.                     , "float", y
  1573.                     , "float", w
  1574.                     , "float", h
  1575.                     , "float", StartAngle
  1576.                     , "float", SweepAngle)
  1577. }
  1578.  
  1579. ;#####################################################################################
  1580.  
  1581. ; Function              Gdip_DrawPie
  1582. ; Description           This function uses a pen to draw the outline of a pie into the Graphics of a bitmap
  1583. ;
  1584. ; pGraphics             Pointer to the Graphics of a bitmap
  1585. ; pPen                  Pointer to a pen
  1586. ; x                     x-coordinate of the start of the pie
  1587. ; y                     y-coordinate of the start of the pie
  1588. ; w                     width of the pie
  1589. ; h                     height of the pie
  1590. ; StartAngle            specifies the angle between the x-axis and the starting point of the pie
  1591. ; SweepAngle            specifies the angle between the starting and ending points of the pie
  1592. ;
  1593. ; return                status enumeration. 0 = success
  1594. ;
  1595. ; notes                 as all coordinates are taken from the top left of each pixel, then the entire width/height should be specified as subtracting the pen width
  1596.  
  1597. Gdip_DrawPie(pGraphics, pPen, x, y, w, h, StartAngle, SweepAngle)
  1598. {
  1599.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1600.    
  1601.     return DllCall("gdiplus\GdipDrawPie", Ptr, pGraphics, Ptr, pPen, "float", x, "float", y, "float", w, "float", h, "float", StartAngle, "float", SweepAngle)
  1602. }
  1603.  
  1604. ;#####################################################################################
  1605.  
  1606. ; Function              Gdip_DrawLine
  1607. ; Description           This function uses a pen to draw a line into the Graphics of a bitmap
  1608. ;
  1609. ; pGraphics             Pointer to the Graphics of a bitmap
  1610. ; pPen                  Pointer to a pen
  1611. ; x1                    x-coordinate of the start of the line
  1612. ; y1                    y-coordinate of the start of the line
  1613. ; x2                    x-coordinate of the end of the line
  1614. ; y2                    y-coordinate of the end of the line
  1615. ;
  1616. ; return                status enumeration. 0 = success    
  1617.  
  1618. Gdip_DrawLine(pGraphics, pPen, x1, y1, x2, y2)
  1619. {
  1620.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1621.    
  1622.     return DllCall("gdiplus\GdipDrawLine"
  1623.                     , Ptr, pGraphics
  1624.                     , Ptr, pPen
  1625.                     , "float", x1
  1626.                     , "float", y1
  1627.                     , "float", x2
  1628.                     , "float", y2)
  1629. }
  1630.  
  1631. ;#####################################################################################
  1632.  
  1633. ; Function              Gdip_DrawLines
  1634. ; Description           This function uses a pen to draw a series of joined lines into the Graphics of a bitmap
  1635. ;
  1636. ; pGraphics             Pointer to the Graphics of a bitmap
  1637. ; pPen                  Pointer to a pen
  1638. ; Points                the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
  1639. ;
  1640. ; return                status enumeration. 0 = success            
  1641.  
  1642. Gdip_DrawLines(pGraphics, pPen, Points)
  1643. {
  1644.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1645.     StringSplit, Points, Points, |
  1646.     VarSetCapacity(PointF, 8*Points0)  
  1647.     Loop, %Points0%
  1648.     {
  1649.         StringSplit, Coord, Points%A_Index%, `,
  1650.         NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
  1651.     }
  1652.     return DllCall("gdiplus\GdipDrawLines", Ptr, pGraphics, Ptr, pPen, Ptr, &PointF, "int", Points0)
  1653. }
  1654.  
  1655. ;#####################################################################################
  1656.  
  1657. ; Function              Gdip_FillRectangle
  1658. ; Description           This function uses a brush to fill a rectangle in the Graphics of a bitmap
  1659. ;
  1660. ; pGraphics             Pointer to the Graphics of a bitmap
  1661. ; pBrush                Pointer to a brush
  1662. ; x                     x-coordinate of the top left of the rectangle
  1663. ; y                     y-coordinate of the top left of the rectangle
  1664. ; w                     width of the rectanlge
  1665. ; h                     height of the rectangle
  1666. ;
  1667. ; return                status enumeration. 0 = success
  1668.  
  1669. Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
  1670. {
  1671.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1672.    
  1673.     return DllCall("gdiplus\GdipFillRectangle"
  1674.                     , Ptr, pGraphics
  1675.                     , Ptr, pBrush
  1676.                     , "float", x
  1677.                     , "float", y
  1678.                     , "float", w
  1679.                     , "float", h)
  1680. }
  1681.  
  1682. ;#####################################################################################
  1683.  
  1684. ; Function              Gdip_FillRoundedRectangle
  1685. ; Description           This function uses a brush to fill a rounded rectangle in the Graphics of a bitmap
  1686. ;
  1687. ; pGraphics             Pointer to the Graphics of a bitmap
  1688. ; pBrush                Pointer to a brush
  1689. ; x                     x-coordinate of the top left of the rounded rectangle
  1690. ; y                     y-coordinate of the top left of the rounded rectangle
  1691. ; w                     width of the rectanlge
  1692. ; h                     height of the rectangle
  1693. ; r                     radius of the rounded corners
  1694. ;
  1695. ; return                status enumeration. 0 = success
  1696.  
  1697. Gdip_FillRoundedRectangle(pGraphics, pBrush, x, y, w, h, r)
  1698. {
  1699.     Region := Gdip_GetClipRegion(pGraphics)
  1700.     Gdip_SetClipRect(pGraphics, x-r, y-r, 2*r, 2*r, 4)
  1701.     Gdip_SetClipRect(pGraphics, x+w-r, y-r, 2*r, 2*r, 4)
  1702.     Gdip_SetClipRect(pGraphics, x-r, y+h-r, 2*r, 2*r, 4)
  1703.     Gdip_SetClipRect(pGraphics, x+w-r, y+h-r, 2*r, 2*r, 4)
  1704.     E := Gdip_FillRectangle(pGraphics, pBrush, x, y, w, h)
  1705.     Gdip_SetClipRegion(pGraphics, Region, 0)
  1706.     Gdip_SetClipRect(pGraphics, x-(2*r), y+r, w+(4*r), h-(2*r), 4)
  1707.     Gdip_SetClipRect(pGraphics, x+r, y-(2*r), w-(2*r), h+(4*r), 4)
  1708.     Gdip_FillEllipse(pGraphics, pBrush, x, y, 2*r, 2*r)
  1709.     Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y, 2*r, 2*r)
  1710.     Gdip_FillEllipse(pGraphics, pBrush, x, y+h-(2*r), 2*r, 2*r)
  1711.     Gdip_FillEllipse(pGraphics, pBrush, x+w-(2*r), y+h-(2*r), 2*r, 2*r)
  1712.     Gdip_SetClipRegion(pGraphics, Region, 0)
  1713.     Gdip_DeleteRegion(Region)
  1714.     return E
  1715. }
  1716.  
  1717. ;#####################################################################################
  1718.  
  1719. ; Function              Gdip_FillPolygon
  1720. ; Description           This function uses a brush to fill a polygon in the Graphics of a bitmap
  1721. ;
  1722. ; pGraphics             Pointer to the Graphics of a bitmap
  1723. ; pBrush                Pointer to a brush
  1724. ; Points                the coordinates of all the points passed as x1,y1|x2,y2|x3,y3.....
  1725. ;
  1726. ; return                status enumeration. 0 = success
  1727. ;
  1728. ; notes                 Alternate will fill the polygon as a whole, wheras winding will fill each new "segment"
  1729. ; Alternate             = 0
  1730. ; Winding               = 1
  1731.  
  1732. Gdip_FillPolygon(pGraphics, pBrush, Points, FillMode=0)
  1733. {
  1734.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1735.    
  1736.     StringSplit, Points, Points, |
  1737.     VarSetCapacity(PointF, 8*Points0)  
  1738.     Loop, %Points0%
  1739.     {
  1740.         StringSplit, Coord, Points%A_Index%, `,
  1741.         NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
  1742.     }  
  1743.     return DllCall("gdiplus\GdipFillPolygon", Ptr, pGraphics, Ptr, pBrush, Ptr, &PointF, "int", Points0, "int", FillMode)
  1744. }
  1745.  
  1746. ;#####################################################################################
  1747.  
  1748. ; Function              Gdip_FillPie
  1749. ; Description           This function uses a brush to fill a pie in the Graphics of a bitmap
  1750. ;
  1751. ; pGraphics             Pointer to the Graphics of a bitmap
  1752. ; pBrush                Pointer to a brush
  1753. ; x                     x-coordinate of the top left of the pie
  1754. ; y                     y-coordinate of the top left of the pie
  1755. ; w                     width of the pie
  1756. ; h                     height of the pie
  1757. ; StartAngle            specifies the angle between the x-axis and the starting point of the pie
  1758. ; SweepAngle            specifies the angle between the starting and ending points of the pie
  1759. ;
  1760. ; return                status enumeration. 0 = success
  1761.  
  1762. Gdip_FillPie(pGraphics, pBrush, x, y, w, h, StartAngle, SweepAngle)
  1763. {
  1764.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1765.    
  1766.     return DllCall("gdiplus\GdipFillPie"
  1767.                     , Ptr, pGraphics
  1768.                     , Ptr, pBrush
  1769.                     , "float", x
  1770.                     , "float", y
  1771.                     , "float", w
  1772.                     , "float", h
  1773.                     , "float", StartAngle
  1774.                     , "float", SweepAngle)
  1775. }
  1776.  
  1777. ;#####################################################################################
  1778.  
  1779. ; Function              Gdip_FillEllipse
  1780. ; Description           This function uses a brush to fill an ellipse in the Graphics of a bitmap
  1781. ;
  1782. ; pGraphics             Pointer to the Graphics of a bitmap
  1783. ; pBrush                Pointer to a brush
  1784. ; x                     x-coordinate of the top left of the ellipse
  1785. ; y                     y-coordinate of the top left of the ellipse
  1786. ; w                     width of the ellipse
  1787. ; h                     height of the ellipse
  1788. ;
  1789. ; return                status enumeration. 0 = success
  1790.  
  1791. Gdip_FillEllipse(pGraphics, pBrush, x, y, w, h)
  1792. {
  1793.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1794.    
  1795.     return DllCall("gdiplus\GdipFillEllipse", Ptr, pGraphics, Ptr, pBrush, "float", x, "float", y, "float", w, "float", h)
  1796. }
  1797.  
  1798. ;#####################################################################################
  1799.  
  1800. ; Function              Gdip_FillRegion
  1801. ; Description           This function uses a brush to fill a region in the Graphics of a bitmap
  1802. ;
  1803. ; pGraphics             Pointer to the Graphics of a bitmap
  1804. ; pBrush                Pointer to a brush
  1805. ; Region                Pointer to a Region
  1806. ;
  1807. ; return                status enumeration. 0 = success
  1808. ;
  1809. ; notes                 You can create a region Gdip_CreateRegion() and then add to this
  1810.  
  1811. Gdip_FillRegion(pGraphics, pBrush, Region)
  1812. {
  1813.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1814.    
  1815.     return DllCall("gdiplus\GdipFillRegion", Ptr, pGraphics, Ptr, pBrush, Ptr, Region)
  1816. }
  1817.  
  1818. ;#####################################################################################
  1819.  
  1820. ; Function              Gdip_FillPath
  1821. ; Description           This function uses a brush to fill a path in the Graphics of a bitmap
  1822. ;
  1823. ; pGraphics             Pointer to the Graphics of a bitmap
  1824. ; pBrush                Pointer to a brush
  1825. ; Region                Pointer to a Path
  1826. ;
  1827. ; return                status enumeration. 0 = success
  1828.  
  1829. Gdip_FillPath(pGraphics, pBrush, Path)
  1830. {
  1831.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1832.    
  1833.     return DllCall("gdiplus\GdipFillPath", Ptr, pGraphics, Ptr, pBrush, Ptr, Path)
  1834. }
  1835.  
  1836. ;#####################################################################################
  1837.  
  1838. ; Function              Gdip_DrawImagePointsRect
  1839. ; Description           This function draws a bitmap into the Graphics of another bitmap and skews it
  1840. ;
  1841. ; pGraphics             Pointer to the Graphics of a bitmap
  1842. ; pBitmap               Pointer to a bitmap to be drawn
  1843. ; Points                Points passed as x1,y1|x2,y2|x3,y3 (3 points: top left, top right, bottom left) describing the drawing of the bitmap
  1844. ; sx                    x-coordinate of source upper-left corner
  1845. ; sy                    y-coordinate of source upper-left corner
  1846. ; sw                    width of source rectangle
  1847. ; sh                    height of source rectangle
  1848. ; Matrix                a matrix used to alter image attributes when drawing
  1849. ;
  1850. ; return                status enumeration. 0 = success
  1851. ;
  1852. ; notes                 if sx,sy,sw,sh are missed then the entire source bitmap will be used
  1853. ;                       Matrix can be omitted to just draw with no alteration to ARGB
  1854. ;                       Matrix may be passed as a digit from 0 - 1 to change just transparency
  1855. ;                       Matrix can be passed as a matrix with any delimiter
  1856.  
  1857. Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx="", sy="", sw="", sh="", Matrix=1)
  1858. {
  1859.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1860.    
  1861.     StringSplit, Points, Points, |
  1862.     VarSetCapacity(PointF, 8*Points0)  
  1863.     Loop, %Points0%
  1864.     {
  1865.         StringSplit, Coord, Points%A_Index%, `,
  1866.         NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
  1867.     }
  1868.  
  1869.     if (Matrix&1 = "")
  1870.         ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
  1871.     else if (Matrix != 1)
  1872.         ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
  1873.        
  1874.     if (sx = "" && sy = "" && sw = "" && sh = "")
  1875.     {
  1876.         sx := 0, sy := 0
  1877.         sw := Gdip_GetImageWidth(pBitmap)
  1878.         sh := Gdip_GetImageHeight(pBitmap)
  1879.     }
  1880.  
  1881.     E := DllCall("gdiplus\GdipDrawImagePointsRect"
  1882.                 , Ptr, pGraphics
  1883.                 , Ptr, pBitmap
  1884.                 , Ptr, &PointF
  1885.                 , "int", Points0
  1886.                 , "float", sx
  1887.                 , "float", sy
  1888.                 , "float", sw
  1889.                 , "float", sh
  1890.                 , "int", 2
  1891.                 , Ptr, ImageAttr
  1892.                 , Ptr, 0
  1893.                 , Ptr, 0)
  1894.     if ImageAttr
  1895.         Gdip_DisposeImageAttributes(ImageAttr)
  1896.     return E
  1897. }
  1898.  
  1899. ;#####################################################################################
  1900.  
  1901. ; Function              Gdip_DrawImage
  1902. ; Description           This function draws a bitmap into the Graphics of another bitmap
  1903. ;
  1904. ; pGraphics             Pointer to the Graphics of a bitmap
  1905. ; pBitmap               Pointer to a bitmap to be drawn
  1906. ; dx                    x-coord of destination upper-left corner
  1907. ; dy                    y-coord of destination upper-left corner
  1908. ; dw                    width of destination image
  1909. ; dh                    height of destination image
  1910. ; sx                    x-coordinate of source upper-left corner
  1911. ; sy                    y-coordinate of source upper-left corner
  1912. ; sw                    width of source image
  1913. ; sh                    height of source image
  1914. ; Matrix                a matrix used to alter image attributes when drawing
  1915. ;
  1916. ; return                status enumeration. 0 = success
  1917. ;
  1918. ; notes                 if sx,sy,sw,sh are missed then the entire source bitmap will be used
  1919. ;                       Gdip_DrawImage performs faster
  1920. ;                       Matrix can be omitted to just draw with no alteration to ARGB
  1921. ;                       Matrix may be passed as a digit from 0 - 1 to change just transparency
  1922. ;                       Matrix can be passed as a matrix with any delimiter. For example:
  1923. ;                       MatrixBright=
  1924. ;                       (
  1925. ;                       1.5     |0      |0      |0      |0
  1926. ;                       0       |1.5    |0      |0      |0
  1927. ;                       0       |0      |1.5    |0      |0
  1928. ;                       0       |0      |0      |1      |0
  1929. ;                       0.05    |0.05   |0.05   |0      |1
  1930. ;                       )
  1931. ;
  1932. ; notes                 MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
  1933. ;                       MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
  1934. ;                       MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
  1935.  
  1936. Gdip_DrawImage(pGraphics, pBitmap, dx="", dy="", dw="", dh="", sx="", sy="", sw="", sh="", Matrix=1)
  1937. {
  1938.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1939.    
  1940.     if (Matrix&1 = "")
  1941.         ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
  1942.     else if (Matrix != 1)
  1943.         ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
  1944.  
  1945.     if (sx = "" && sy = "" && sw = "" && sh = "")
  1946.     {
  1947.         if (dx = "" && dy = "" && dw = "" && dh = "")
  1948.         {
  1949.             sx := dx := 0, sy := dy := 0
  1950.             sw := dw := Gdip_GetImageWidth(pBitmap)
  1951.             sh := dh := Gdip_GetImageHeight(pBitmap)
  1952.         }
  1953.         else
  1954.         {
  1955.             sx := sy := 0
  1956.             sw := Gdip_GetImageWidth(pBitmap)
  1957.             sh := Gdip_GetImageHeight(pBitmap)
  1958.         }
  1959.     }
  1960.  
  1961.     E := DllCall("gdiplus\GdipDrawImageRectRect"
  1962.                 , Ptr, pGraphics
  1963.                 , Ptr, pBitmap
  1964.                 , "float", dx
  1965.                 , "float", dy
  1966.                 , "float", dw
  1967.                 , "float", dh
  1968.                 , "float", sx
  1969.                 , "float", sy
  1970.                 , "float", sw
  1971.                 , "float", sh
  1972.                 , "int", 2
  1973.                 , Ptr, ImageAttr
  1974.                 , Ptr, 0
  1975.                 , Ptr, 0)
  1976.     if ImageAttr
  1977.         Gdip_DisposeImageAttributes(ImageAttr)
  1978.     return E
  1979. }
  1980.  
  1981. ;#####################################################################################
  1982.  
  1983. ; Function              Gdip_SetImageAttributesColorMatrix
  1984. ; Description           This function creates an image matrix ready for drawing
  1985. ;
  1986. ; Matrix                a matrix used to alter image attributes when drawing
  1987. ;                       passed with any delimeter
  1988. ;
  1989. ; return                returns an image matrix on sucess or 0 if it fails
  1990. ;
  1991. ; notes                 MatrixBright = 1.5|0|0|0|0|0|1.5|0|0|0|0|0|1.5|0|0|0|0|0|1|0|0.05|0.05|0.05|0|1
  1992. ;                       MatrixGreyScale = 0.299|0.299|0.299|0|0|0.587|0.587|0.587|0|0|0.114|0.114|0.114|0|0|0|0|0|1|0|0|0|0|0|1
  1993. ;                       MatrixNegative = -1|0|0|0|0|0|-1|0|0|0|0|0|-1|0|0|0|0|0|1|0|0|0|0|0|1
  1994.  
  1995. Gdip_SetImageAttributesColorMatrix(Matrix)
  1996. {
  1997.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  1998.    
  1999.     VarSetCapacity(ColourMatrix, 100, 0)
  2000.     Matrix := RegExReplace(RegExReplace(Matrix, "^[^\d-\.]+([\d\.])", "$1", "", 1), "[^\d-\.]+", "|")
  2001.     StringSplit, Matrix, Matrix, |
  2002.     Loop, 25
  2003.     {
  2004.         Matrix := (Matrix%A_Index% != "") ? Matrix%A_Index% : Mod(A_Index-1, 6) ? 0 : 1
  2005.         NumPut(Matrix, ColourMatrix, (A_Index-1)*4, "float")
  2006.     }
  2007.     DllCall("gdiplus\GdipCreateImageAttributes", A_PtrSize ? "UPtr*" : "uint*", ImageAttr)
  2008.     DllCall("gdiplus\GdipSetImageAttributesColorMatrix", Ptr, ImageAttr, "int", 1, "int", 1, Ptr, &ColourMatrix, Ptr, 0, "int", 0)
  2009.     return ImageAttr
  2010. }
  2011.  
  2012. ;#####################################################################################
  2013.  
  2014. ; Function              Gdip_GraphicsFromImage
  2015. ; Description           This function gets the graphics for a bitmap used for drawing functions
  2016. ;
  2017. ; pBitmap               Pointer to a bitmap to get the pointer to its graphics
  2018. ;
  2019. ; return                returns a pointer to the graphics of a bitmap
  2020. ;
  2021. ; notes                 a bitmap can be drawn into the graphics of another bitmap
  2022.  
  2023. Gdip_GraphicsFromImage(pBitmap)
  2024. {
  2025.     DllCall("gdiplus\GdipGetImageGraphicsContext", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
  2026.     return pGraphics
  2027. }
  2028.  
  2029. ;#####################################################################################
  2030.  
  2031. ; Function              Gdip_GraphicsFromHDC
  2032. ; Description           This function gets the graphics from the handle to a device context
  2033. ;
  2034. ; hdc                   This is the handle to the device context
  2035. ;
  2036. ; return                returns a pointer to the graphics of a bitmap
  2037. ;
  2038. ; notes                 You can draw a bitmap into the graphics of another bitmap
  2039.  
  2040. Gdip_GraphicsFromHDC(hdc)
  2041. {
  2042.     DllCall("gdiplus\GdipCreateFromHDC", A_PtrSize ? "UPtr" : "UInt", hdc, A_PtrSize ? "UPtr*" : "UInt*", pGraphics)
  2043.     return pGraphics
  2044. }
  2045.  
  2046. ;#####################################################################################
  2047.  
  2048. ; Function              Gdip_GetDC
  2049. ; Description           This function gets the device context of the passed Graphics
  2050. ;
  2051. ; hdc                   This is the handle to the device context
  2052. ;
  2053. ; return                returns the device context for the graphics of a bitmap
  2054.  
  2055. Gdip_GetDC(pGraphics)
  2056. {
  2057.     DllCall("gdiplus\GdipGetDC", A_PtrSize ? "UPtr" : "UInt", pGraphics, A_PtrSize ? "UPtr*" : "UInt*", hdc)
  2058.     return hdc
  2059. }
  2060.  
  2061. ;#####################################################################################
  2062.  
  2063. ; Function              Gdip_ReleaseDC
  2064. ; Description           This function releases a device context from use for further use
  2065. ;
  2066. ; pGraphics             Pointer to the graphics of a bitmap
  2067. ; hdc                   This is the handle to the device context
  2068. ;
  2069. ; return                status enumeration. 0 = success
  2070.  
  2071. Gdip_ReleaseDC(pGraphics, hdc)
  2072. {
  2073.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2074.    
  2075.     return DllCall("gdiplus\GdipReleaseDC", Ptr, pGraphics, Ptr, hdc)
  2076. }
  2077.  
  2078. ;#####################################################################################
  2079.  
  2080. ; Function              Gdip_GraphicsClear
  2081. ; Description           Clears the graphics of a bitmap ready for further drawing
  2082. ;
  2083. ; pGraphics             Pointer to the graphics of a bitmap
  2084. ; ARGB                  The colour to clear the graphics to
  2085. ;
  2086. ; return                status enumeration. 0 = success
  2087. ;
  2088. ; notes                 By default this will make the background invisible
  2089. ;                       Using clipping regions you can clear a particular area on the graphics rather than clearing the entire graphics
  2090.  
  2091. Gdip_GraphicsClear(pGraphics, ARGB=0x00ffffff)
  2092. {
  2093.     return DllCall("gdiplus\GdipGraphicsClear", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", ARGB)
  2094. }
  2095.  
  2096. ;#####################################################################################
  2097.  
  2098. ; Function              Gdip_BlurBitmap
  2099. ; Description           Gives a pointer to a blurred bitmap from a pointer to a bitmap
  2100. ;
  2101. ; pBitmap               Pointer to a bitmap to be blurred
  2102. ; Blur                  The Amount to blur a bitmap by from 1 (least blur) to 100 (most blur)
  2103. ;
  2104. ; return                If the function succeeds, the return value is a pointer to the new blurred bitmap
  2105. ;                       -1 = The blur parameter is outside the range 1-100
  2106. ;
  2107. ; notes                 This function will not dispose of the original bitmap
  2108.  
  2109. Gdip_BlurBitmap(pBitmap, Blur)
  2110. {
  2111.     if (Blur > 100) || (Blur < 1)
  2112.         return -1  
  2113.    
  2114.     sWidth := Gdip_GetImageWidth(pBitmap), sHeight := Gdip_GetImageHeight(pBitmap)
  2115.     dWidth := sWidth//Blur, dHeight := sHeight//Blur
  2116.  
  2117.     pBitmap1 := Gdip_CreateBitmap(dWidth, dHeight)
  2118.     G1 := Gdip_GraphicsFromImage(pBitmap1)
  2119.     Gdip_SetInterpolationMode(G1, 7)
  2120.     Gdip_DrawImage(G1, pBitmap, 0, 0, dWidth, dHeight, 0, 0, sWidth, sHeight)
  2121.  
  2122.     Gdip_DeleteGraphics(G1)
  2123.  
  2124.     pBitmap2 := Gdip_CreateBitmap(sWidth, sHeight)
  2125.     G2 := Gdip_GraphicsFromImage(pBitmap2)
  2126.     Gdip_SetInterpolationMode(G2, 7)
  2127.     Gdip_DrawImage(G2, pBitmap1, 0, 0, sWidth, sHeight, 0, 0, dWidth, dHeight)
  2128.  
  2129.     Gdip_DeleteGraphics(G2)
  2130.     Gdip_DisposeImage(pBitmap1)
  2131.     return pBitmap2
  2132. }
  2133.  
  2134. ;#####################################################################################
  2135.  
  2136. ; Function:             Gdip_SaveBitmapToFile
  2137. ; Description:          Saves a bitmap to a file in any supported format onto disk
  2138. ;  
  2139. ; pBitmap               Pointer to a bitmap
  2140. ; sOutput               The name of the file that the bitmap will be saved to. Supported extensions are: .BMP,.DIB,.RLE,.JPG,.JPEG,.JPE,.JFIF,.GIF,.TIF,.TIFF,.PNG
  2141. ; Quality               If saving as jpg (.JPG,.JPEG,.JPE,.JFIF) then quality can be 1-100 with default at maximum quality
  2142. ;
  2143. ; return                If the function succeeds, the return value is zero, otherwise:
  2144. ;                       -1 = Extension supplied is not a supported file format
  2145. ;                       -2 = Could not get a list of encoders on system
  2146. ;                       -3 = Could not find matching encoder for specified file format
  2147. ;                       -4 = Could not get WideChar name of output file
  2148. ;                       -5 = Could not save file to disk
  2149. ;
  2150. ; notes                 This function will use the extension supplied from the sOutput parameter to determine the output format
  2151.  
  2152. Gdip_SaveBitmapToFile(pBitmap, sOutput, Quality=75)
  2153. {
  2154.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2155.    
  2156.     SplitPath, sOutput,,, Extension
  2157.     if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
  2158.         return -1
  2159.     Extension := "." Extension
  2160.  
  2161.     DllCall("gdiplus\GdipGetImageEncodersSize", "uint*", nCount, "uint*", nSize)
  2162.     VarSetCapacity(ci, nSize)
  2163.     DllCall("gdiplus\GdipGetImageEncoders", "uint", nCount, "uint", nSize, Ptr, &ci)
  2164.     if !(nCount && nSize)
  2165.         return -2
  2166.    
  2167.     If (A_IsUnicode){
  2168.         StrGet_Name := "StrGet"
  2169.         Loop, %nCount%
  2170.         {
  2171.             sString := %StrGet_Name%(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), "UTF-16")
  2172.             if !InStr(sString, "*" Extension)
  2173.                 continue
  2174.            
  2175.             pCodec := &ci+idx
  2176.             break
  2177.         }
  2178.     } else {
  2179.         Loop, %nCount%
  2180.         {
  2181.             Location := NumGet(ci, 76*(A_Index-1)+44)
  2182.             nSize := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "uint", 0, "int",  0, "uint", 0, "uint", 0)
  2183.             VarSetCapacity(sString, nSize)
  2184.             DllCall("WideCharToMultiByte", "uint", 0, "uint", 0, "uint", Location, "int", -1, "str", sString, "int", nSize, "uint", 0, "uint", 0)
  2185.             if !InStr(sString, "*" Extension)
  2186.                 continue
  2187.            
  2188.             pCodec := &ci+76*(A_Index-1)
  2189.             break
  2190.         }
  2191.     }
  2192.    
  2193.     if !pCodec
  2194.         return -3
  2195.  
  2196.     if (Quality != 75)
  2197.     {
  2198.         Quality := (Quality < 0) ? 0 : (Quality > 100) ? 100 : Quality
  2199.         if Extension in .JPG,.JPEG,.JPE,.JFIF
  2200.         {
  2201.             DllCall("gdiplus\GdipGetEncoderParameterListSize", Ptr, pBitmap, Ptr, pCodec, "uint*", nSize)
  2202.             VarSetCapacity(EncoderParameters, nSize, 0)
  2203.             DllCall("gdiplus\GdipGetEncoderParameterList", Ptr, pBitmap, Ptr, pCodec, "uint", nSize, Ptr, &EncoderParameters)
  2204.             Loop, % NumGet(EncoderParameters, "UInt")      ;%
  2205.             {
  2206.                 elem := (24+(A_PtrSize ? A_PtrSize : 4))*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
  2207.                 if (NumGet(EncoderParameters, elem+16, "UInt") = 1) && (NumGet(EncoderParameters, elem+20, "UInt") = 6)
  2208.                 {
  2209.                     p := elem+&EncoderParameters-pad-4
  2210.                     NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, "UInt")), "UInt")
  2211.                     break
  2212.                 }
  2213.             }      
  2214.         }
  2215.     }
  2216.  
  2217.     if (!A_IsUnicode)
  2218.     {
  2219.         nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, 0, "int", 0)
  2220.         VarSetCapacity(wOutput, nSize*2)
  2221.         DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sOutput, "int", -1, Ptr, &wOutput, "int", nSize)
  2222.         VarSetCapacity(wOutput, -1)
  2223.         if !VarSetCapacity(wOutput)
  2224.             return -4
  2225.         E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &wOutput, Ptr, pCodec, "uint", p ? p : 0)
  2226.     }
  2227.     else
  2228.         E := DllCall("gdiplus\GdipSaveImageToFile", Ptr, pBitmap, Ptr, &sOutput, Ptr, pCodec, "uint", p ? p : 0)
  2229.     return E ? -5 : 0
  2230. }
  2231.  
  2232. ;#####################################################################################
  2233.  
  2234. ; Function              Gdip_GetPixel
  2235. ; Description           Gets the ARGB of a pixel in a bitmap
  2236. ;
  2237. ; pBitmap               Pointer to a bitmap
  2238. ; x                     x-coordinate of the pixel
  2239. ; y                     y-coordinate of the pixel
  2240. ;
  2241. ; return                Returns the ARGB value of the pixel
  2242.  
  2243. Gdip_GetPixel(pBitmap, x, y)
  2244. {
  2245.     DllCall("gdiplus\GdipBitmapGetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "uint*", ARGB)
  2246.     return ARGB
  2247. }
  2248.  
  2249. ;#####################################################################################
  2250.  
  2251. ; Function              Gdip_SetPixel
  2252. ; Description           Sets the ARGB of a pixel in a bitmap
  2253. ;
  2254. ; pBitmap               Pointer to a bitmap
  2255. ; x                     x-coordinate of the pixel
  2256. ; y                     y-coordinate of the pixel
  2257. ;
  2258. ; return                status enumeration. 0 = success
  2259.  
  2260. Gdip_SetPixel(pBitmap, x, y, ARGB)
  2261. {
  2262.    return DllCall("gdiplus\GdipBitmapSetPixel", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", x, "int", y, "int", ARGB)
  2263. }
  2264.  
  2265. ;#####################################################################################
  2266.  
  2267. ; Function              Gdip_GetImageWidth
  2268. ; Description           Gives the width of a bitmap
  2269. ;
  2270. ; pBitmap               Pointer to a bitmap
  2271. ;
  2272. ; return                Returns the width in pixels of the supplied bitmap
  2273.  
  2274. Gdip_GetImageWidth(pBitmap)
  2275. {
  2276.    DllCall("gdiplus\GdipGetImageWidth", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Width)
  2277.    return Width
  2278. }
  2279.  
  2280. ;#####################################################################################
  2281.  
  2282. ; Function              Gdip_GetImageHeight
  2283. ; Description           Gives the height of a bitmap
  2284. ;
  2285. ; pBitmap               Pointer to a bitmap
  2286. ;
  2287. ; return                Returns the height in pixels of the supplied bitmap
  2288.  
  2289. Gdip_GetImageHeight(pBitmap)
  2290. {
  2291.    DllCall("gdiplus\GdipGetImageHeight", A_PtrSize ? "UPtr" : "UInt", pBitmap, "uint*", Height)
  2292.    return Height
  2293. }
  2294.  
  2295. ;#####################################################################################
  2296.  
  2297. ; Function              Gdip_GetDimensions
  2298. ; Description           Gives the width and height of a bitmap
  2299. ;
  2300. ; pBitmap               Pointer to a bitmap
  2301. ; Width                 ByRef variable. This variable will be set to the width of the bitmap
  2302. ; Height                ByRef variable. This variable will be set to the height of the bitmap
  2303. ;
  2304. ; return                No return value
  2305. ;                       Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
  2306.  
  2307. Gdip_GetImageDimensions(pBitmap, ByRef Width, ByRef Height)
  2308. {
  2309.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2310.     DllCall("gdiplus\GdipGetImageWidth", Ptr, pBitmap, "uint*", Width)
  2311.     DllCall("gdiplus\GdipGetImageHeight", Ptr, pBitmap, "uint*", Height)
  2312. }
  2313.  
  2314. ;#####################################################################################
  2315.  
  2316. Gdip_GetDimensions(pBitmap, ByRef Width, ByRef Height)
  2317. {
  2318.     Gdip_GetImageDimensions(pBitmap, Width, Height)
  2319. }
  2320.  
  2321. ;#####################################################################################
  2322.  
  2323. Gdip_GetImagePixelFormat(pBitmap)
  2324. {
  2325.     DllCall("gdiplus\GdipGetImagePixelFormat", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "UInt*", Format)
  2326.     return Format
  2327. }
  2328.  
  2329. ;#####################################################################################
  2330.  
  2331. ; Function              Gdip_GetDpiX
  2332. ; Description           Gives the horizontal dots per inch of the graphics of a bitmap
  2333. ;
  2334. ; pBitmap               Pointer to a bitmap
  2335. ; Width                 ByRef variable. This variable will be set to the width of the bitmap
  2336. ; Height                ByRef variable. This variable will be set to the height of the bitmap
  2337. ;
  2338. ; return                No return value
  2339. ;                       Gdip_GetDimensions(pBitmap, ThisWidth, ThisHeight) will set ThisWidth to the width and ThisHeight to the height
  2340.  
  2341. Gdip_GetDpiX(pGraphics)
  2342. {
  2343.     DllCall("gdiplus\GdipGetDpiX", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpix)
  2344.     return Round(dpix)
  2345. }
  2346.  
  2347. ;#####################################################################################
  2348.  
  2349. Gdip_GetDpiY(pGraphics)
  2350. {
  2351.     DllCall("gdiplus\GdipGetDpiY", A_PtrSize ? "UPtr" : "uint", pGraphics, "float*", dpiy)
  2352.     return Round(dpiy)
  2353. }
  2354.  
  2355. ;#####################################################################################
  2356.  
  2357. Gdip_GetImageHorizontalResolution(pBitmap)
  2358. {
  2359.     DllCall("gdiplus\GdipGetImageHorizontalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpix)
  2360.     return Round(dpix)
  2361. }
  2362.  
  2363. ;#####################################################################################
  2364.  
  2365. Gdip_GetImageVerticalResolution(pBitmap)
  2366. {
  2367.     DllCall("gdiplus\GdipGetImageVerticalResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float*", dpiy)
  2368.     return Round(dpiy)
  2369. }
  2370.  
  2371. ;#####################################################################################
  2372.  
  2373. Gdip_BitmapSetResolution(pBitmap, dpix, dpiy)
  2374. {
  2375.     return DllCall("gdiplus\GdipBitmapSetResolution", A_PtrSize ? "UPtr" : "uint", pBitmap, "float", dpix, "float", dpiy)
  2376. }
  2377.  
  2378. ;#####################################################################################
  2379.  
  2380. Gdip_CreateBitmapFromFile(sFile, IconNumber=1, IconSize="")
  2381. {
  2382.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2383.     , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
  2384.    
  2385.     SplitPath, sFile,,, ext
  2386.     if ext in exe,dll
  2387.     {
  2388.         Sizes := IconSize ? IconSize : 256 "|" 128 "|" 64 "|" 48 "|" 32 "|" 16
  2389.         BufSize := 16 + (2*(A_PtrSize ? A_PtrSize : 4))
  2390.        
  2391.         VarSetCapacity(buf, BufSize, 0)
  2392.         Loop, Parse, Sizes, |
  2393.         {
  2394.             DllCall("PrivateExtractIcons", "str", sFile, "int", IconNumber-1, "int", A_LoopField, "int", A_LoopField, PtrA, hIcon, PtrA, 0, "uint", 1, "uint", 0)
  2395.            
  2396.             if !hIcon
  2397.                 continue
  2398.  
  2399.             if !DllCall("GetIconInfo", Ptr, hIcon, Ptr, &buf)
  2400.             {
  2401.                 DestroyIcon(hIcon)
  2402.                 continue
  2403.             }
  2404.            
  2405.             hbmMask  := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4))
  2406.             hbmColor := NumGet(buf, 12 + ((A_PtrSize ? A_PtrSize : 4) - 4) + (A_PtrSize ? A_PtrSize : 4))
  2407.             if !(hbmColor && DllCall("GetObject", Ptr, hbmColor, "int", BufSize, Ptr, &buf))
  2408.             {
  2409.                 DestroyIcon(hIcon)
  2410.                 continue
  2411.             }
  2412.             break
  2413.         }
  2414.         if !hIcon
  2415.             return -1
  2416.  
  2417.         Width := NumGet(buf, 4, "int"), Height := NumGet(buf, 8, "int")
  2418.         hbm := CreateDIBSection(Width, -Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
  2419.         if !DllCall("DrawIconEx", Ptr, hdc, "int", 0, "int", 0, Ptr, hIcon, "uint", Width, "uint", Height, "uint", 0, Ptr, 0, "uint", 3)
  2420.         {
  2421.             DestroyIcon(hIcon)
  2422.             return -2
  2423.         }
  2424.        
  2425.         VarSetCapacity(dib, 104)
  2426.         DllCall("GetObject", Ptr, hbm, "int", A_PtrSize = 8 ? 104 : 84, Ptr, &dib) ; sizeof(DIBSECTION) = 76+2*(A_PtrSize=8?4:0)+2*A_PtrSize
  2427.         Stride := NumGet(dib, 12, "Int"), Bits := NumGet(dib, 20 + (A_PtrSize = 8 ? 4 : 0)) ; padding
  2428.         DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", Stride, "int", 0x26200A, Ptr, Bits, PtrA, pBitmapOld)
  2429.         pBitmap := Gdip_CreateBitmap(Width, Height)
  2430.         G := Gdip_GraphicsFromImage(pBitmap)
  2431.         , Gdip_DrawImage(G, pBitmapOld, 0, 0, Width, Height, 0, 0, Width, Height)
  2432.         SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
  2433.         Gdip_DeleteGraphics(G), Gdip_DisposeImage(pBitmapOld)
  2434.         DestroyIcon(hIcon)
  2435.     }
  2436.     else
  2437.     {
  2438.         if (!A_IsUnicode)
  2439.         {
  2440.             VarSetCapacity(wFile, 1024)
  2441.             DllCall("kernel32\MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sFile, "int", -1, Ptr, &wFile, "int", 512)
  2442.             DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &wFile, PtrA, pBitmap)
  2443.         }
  2444.         else
  2445.             DllCall("gdiplus\GdipCreateBitmapFromFile", Ptr, &sFile, PtrA, pBitmap)
  2446.     }
  2447.    
  2448.     return pBitmap
  2449. }
  2450.  
  2451. ;#####################################################################################
  2452.  
  2453. Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
  2454. {
  2455.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2456.    
  2457.     DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", Ptr, hBitmap, Ptr, Palette, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
  2458.     return pBitmap
  2459. }
  2460.  
  2461. ;#####################################################################################
  2462.  
  2463. Gdip_CreateHBITMAPFromBitmap(pBitmap, Background=0xffffffff)
  2464. {
  2465.     DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hbm, "int", Background)
  2466.     return hbm
  2467. }
  2468.  
  2469. ;#####################################################################################
  2470.  
  2471. Gdip_CreateBitmapFromHICON(hIcon)
  2472. {
  2473.     DllCall("gdiplus\GdipCreateBitmapFromHICON", A_PtrSize ? "UPtr" : "UInt", hIcon, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
  2474.     return pBitmap
  2475. }
  2476.  
  2477. ;#####################################################################################
  2478.  
  2479. Gdip_CreateHICONFromBitmap(pBitmap)
  2480. {
  2481.     DllCall("gdiplus\GdipCreateHICONFromBitmap", A_PtrSize ? "UPtr" : "UInt", pBitmap, A_PtrSize ? "UPtr*" : "uint*", hIcon)
  2482.     return hIcon
  2483. }
  2484.  
  2485. ;#####################################################################################
  2486.  
  2487. Gdip_CreateBitmap(Width, Height, Format=0x26200A)
  2488. {
  2489.     DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", Width, "int", Height, "int", 0, "int", Format, A_PtrSize ? "UPtr" : "UInt", 0, A_PtrSize ? "UPtr*" : "uint*", pBitmap)
  2490.     Return pBitmap
  2491. }
  2492.  
  2493. ;#####################################################################################
  2494.  
  2495. Gdip_CreateBitmapFromClipboard()
  2496. {
  2497.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2498.    
  2499.     if !DllCall("OpenClipboard", Ptr, 0)
  2500.         return -1
  2501.     if !DllCall("IsClipboardFormatAvailable", "uint", 8)
  2502.         return -2
  2503.     if !hBitmap := DllCall("GetClipboardData", "uint", 2, Ptr)
  2504.         return -3
  2505.     if !pBitmap := Gdip_CreateBitmapFromHBITMAP(hBitmap)
  2506.         return -4
  2507.     if !DllCall("CloseClipboard")
  2508.         return -5
  2509.     DeleteObject(hBitmap)
  2510.     return pBitmap
  2511. }
  2512.  
  2513. ;#####################################################################################
  2514.  
  2515. Gdip_SetBitmapToClipboard(pBitmap)
  2516. {
  2517.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2518.     off1 := A_PtrSize = 8 ? 52 : 44, off2 := A_PtrSize = 8 ? 32 : 24
  2519.     hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
  2520.     DllCall("GetObject", Ptr, hBitmap, "int", VarSetCapacity(oi, A_PtrSize = 8 ? 104 : 84, 0), Ptr, &oi)
  2521.     hdib := DllCall("GlobalAlloc", "uint", 2, Ptr, 40+NumGet(oi, off1, "UInt"), Ptr)
  2522.     pdib := DllCall("GlobalLock", Ptr, hdib, Ptr)
  2523.     DllCall("RtlMoveMemory", Ptr, pdib, Ptr, &oi+off2, Ptr, 40)
  2524.     DllCall("RtlMoveMemory", Ptr, pdib+40, Ptr, NumGet(oi, off2 - (A_PtrSize ? A_PtrSize : 4), Ptr), Ptr, NumGet(oi, off1, "UInt"))
  2525.     DllCall("GlobalUnlock", Ptr, hdib)
  2526.     DllCall("DeleteObject", Ptr, hBitmap)
  2527.     DllCall("OpenClipboard", Ptr, 0)
  2528.     DllCall("EmptyClipboard")
  2529.     DllCall("SetClipboardData", "uint", 8, Ptr, hdib)
  2530.     DllCall("CloseClipboard")
  2531. }
  2532.  
  2533. ;#####################################################################################
  2534.  
  2535. Gdip_CloneBitmapArea(pBitmap, x, y, w, h, Format=0x26200A)
  2536. {
  2537.     DllCall("gdiplus\GdipCloneBitmapArea"
  2538.                     , "float", x
  2539.                     , "float", y
  2540.                     , "float", w
  2541.                     , "float", h
  2542.                     , "int", Format
  2543.                     , A_PtrSize ? "UPtr" : "UInt", pBitmap
  2544.                     , A_PtrSize ? "UPtr*" : "UInt*", pBitmapDest)
  2545.     return pBitmapDest
  2546. }
  2547.  
  2548. ;#####################################################################################
  2549. ; Create resources
  2550. ;#####################################################################################
  2551.  
  2552. Gdip_CreatePen(ARGB, w)
  2553. {
  2554.    DllCall("gdiplus\GdipCreatePen1", "UInt", ARGB, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
  2555.    return pPen
  2556. }
  2557.  
  2558. ;#####################################################################################
  2559.  
  2560. Gdip_CreatePenFromBrush(pBrush, w)
  2561. {
  2562.     DllCall("gdiplus\GdipCreatePen2", A_PtrSize ? "UPtr" : "UInt", pBrush, "float", w, "int", 2, A_PtrSize ? "UPtr*" : "UInt*", pPen)
  2563.     return pPen
  2564. }
  2565.  
  2566. ;#####################################################################################
  2567.  
  2568. Gdip_BrushCreateSolid(ARGB=0xff000000)
  2569. {
  2570.     DllCall("gdiplus\GdipCreateSolidFill", "UInt", ARGB, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
  2571.     return pBrush
  2572. }
  2573.  
  2574. ;#####################################################################################
  2575.  
  2576. ; HatchStyleHorizontal = 0
  2577. ; HatchStyleVertical = 1
  2578. ; HatchStyleForwardDiagonal = 2
  2579. ; HatchStyleBackwardDiagonal = 3
  2580. ; HatchStyleCross = 4
  2581. ; HatchStyleDiagonalCross = 5
  2582. ; HatchStyle05Percent = 6
  2583. ; HatchStyle10Percent = 7
  2584. ; HatchStyle20Percent = 8
  2585. ; HatchStyle25Percent = 9
  2586. ; HatchStyle30Percent = 10
  2587. ; HatchStyle40Percent = 11
  2588. ; HatchStyle50Percent = 12
  2589. ; HatchStyle60Percent = 13
  2590. ; HatchStyle70Percent = 14
  2591. ; HatchStyle75Percent = 15
  2592. ; HatchStyle80Percent = 16
  2593. ; HatchStyle90Percent = 17
  2594. ; HatchStyleLightDownwardDiagonal = 18
  2595. ; HatchStyleLightUpwardDiagonal = 19
  2596. ; HatchStyleDarkDownwardDiagonal = 20
  2597. ; HatchStyleDarkUpwardDiagonal = 21
  2598. ; HatchStyleWideDownwardDiagonal = 22
  2599. ; HatchStyleWideUpwardDiagonal = 23
  2600. ; HatchStyleLightVertical = 24
  2601. ; HatchStyleLightHorizontal = 25
  2602. ; HatchStyleNarrowVertical = 26
  2603. ; HatchStyleNarrowHorizontal = 27
  2604. ; HatchStyleDarkVertical = 28
  2605. ; HatchStyleDarkHorizontal = 29
  2606. ; HatchStyleDashedDownwardDiagonal = 30
  2607. ; HatchStyleDashedUpwardDiagonal = 31
  2608. ; HatchStyleDashedHorizontal = 32
  2609. ; HatchStyleDashedVertical = 33
  2610. ; HatchStyleSmallConfetti = 34
  2611. ; HatchStyleLargeConfetti = 35
  2612. ; HatchStyleZigZag = 36
  2613. ; HatchStyleWave = 37
  2614. ; HatchStyleDiagonalBrick = 38
  2615. ; HatchStyleHorizontalBrick = 39
  2616. ; HatchStyleWeave = 40
  2617. ; HatchStylePlaid = 41
  2618. ; HatchStyleDivot = 42
  2619. ; HatchStyleDottedGrid = 43
  2620. ; HatchStyleDottedDiamond = 44
  2621. ; HatchStyleShingle = 45
  2622. ; HatchStyleTrellis = 46
  2623. ; HatchStyleSphere = 47
  2624. ; HatchStyleSmallGrid = 48
  2625. ; HatchStyleSmallCheckerBoard = 49
  2626. ; HatchStyleLargeCheckerBoard = 50
  2627. ; HatchStyleOutlinedDiamond = 51
  2628. ; HatchStyleSolidDiamond = 52
  2629. ; HatchStyleTotal = 53
  2630. Gdip_BrushCreateHatch(ARGBfront, ARGBback, HatchStyle=0)
  2631. {
  2632.     DllCall("gdiplus\GdipCreateHatchBrush", "int", HatchStyle, "UInt", ARGBfront, "UInt", ARGBback, A_PtrSize ? "UPtr*" : "UInt*", pBrush)
  2633.     return pBrush
  2634. }
  2635.  
  2636. ;#####################################################################################
  2637.  
  2638. Gdip_CreateTextureBrush(pBitmap, WrapMode=1, x=0, y=0, w="", h="")
  2639. {
  2640.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2641.     , PtrA := A_PtrSize ? "UPtr*" : "UInt*"
  2642.    
  2643.     if !(w && h)
  2644.         DllCall("gdiplus\GdipCreateTexture", Ptr, pBitmap, "int", WrapMode, PtrA, pBrush)
  2645.     else
  2646.         DllCall("gdiplus\GdipCreateTexture2", Ptr, pBitmap, "int", WrapMode, "float", x, "float", y, "float", w, "float", h, PtrA, pBrush)
  2647.     return pBrush
  2648. }
  2649.  
  2650. ;#####################################################################################
  2651.  
  2652. ; WrapModeTile = 0
  2653. ; WrapModeTileFlipX = 1
  2654. ; WrapModeTileFlipY = 2
  2655. ; WrapModeTileFlipXY = 3
  2656. ; WrapModeClamp = 4
  2657. Gdip_CreateLineBrush(x1, y1, x2, y2, ARGB1, ARGB2, WrapMode=1)
  2658. {
  2659.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2660.    
  2661.     CreatePointF(PointF1, x1, y1), CreatePointF(PointF2, x2, y2)
  2662.     DllCall("gdiplus\GdipCreateLineBrush", Ptr, &PointF1, Ptr, &PointF2, "Uint", ARGB1, "Uint", ARGB2, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
  2663.     return LGpBrush
  2664. }
  2665.  
  2666. ;#####################################################################################
  2667.  
  2668. ; LinearGradientModeHorizontal = 0
  2669. ; LinearGradientModeVertical = 1
  2670. ; LinearGradientModeForwardDiagonal = 2
  2671. ; LinearGradientModeBackwardDiagonal = 3
  2672. Gdip_CreateLineBrushFromRect(x, y, w, h, ARGB1, ARGB2, LinearGradientMode=1, WrapMode=1)
  2673. {
  2674.     CreateRectF(RectF, x, y, w, h)
  2675.     DllCall("gdiplus\GdipCreateLineBrushFromRect", A_PtrSize ? "UPtr" : "UInt", &RectF, "int", ARGB1, "int", ARGB2, "int", LinearGradientMode, "int", WrapMode, A_PtrSize ? "UPtr*" : "UInt*", LGpBrush)
  2676.     return LGpBrush
  2677. }
  2678.  
  2679. ;#####################################################################################
  2680.  
  2681. Gdip_CloneBrush(pBrush)
  2682. {
  2683.     DllCall("gdiplus\GdipCloneBrush", A_PtrSize ? "UPtr" : "UInt", pBrush, A_PtrSize ? "UPtr*" : "UInt*", pBrushClone)
  2684.     return pBrushClone
  2685. }
  2686.  
  2687. ;#####################################################################################
  2688. ; Delete resources
  2689. ;#####################################################################################
  2690.  
  2691. Gdip_DeletePen(pPen)
  2692. {
  2693.    return DllCall("gdiplus\GdipDeletePen", A_PtrSize ? "UPtr" : "UInt", pPen)
  2694. }
  2695.  
  2696. ;#####################################################################################
  2697.  
  2698. Gdip_DeleteBrush(pBrush)
  2699. {
  2700.    return DllCall("gdiplus\GdipDeleteBrush", A_PtrSize ? "UPtr" : "UInt", pBrush)
  2701. }
  2702.  
  2703. ;#####################################################################################
  2704.  
  2705. Gdip_DisposeImage(pBitmap)
  2706. {
  2707.    return DllCall("gdiplus\GdipDisposeImage", A_PtrSize ? "UPtr" : "UInt", pBitmap)
  2708. }
  2709.  
  2710. ;#####################################################################################
  2711.  
  2712. Gdip_DeleteGraphics(pGraphics)
  2713. {
  2714.    return DllCall("gdiplus\GdipDeleteGraphics", A_PtrSize ? "UPtr" : "UInt", pGraphics)
  2715. }
  2716.  
  2717. ;#####################################################################################
  2718.  
  2719. Gdip_DisposeImageAttributes(ImageAttr)
  2720. {
  2721.     return DllCall("gdiplus\GdipDisposeImageAttributes", A_PtrSize ? "UPtr" : "UInt", ImageAttr)
  2722. }
  2723.  
  2724. ;#####################################################################################
  2725.  
  2726. Gdip_DeleteFont(hFont)
  2727. {
  2728.    return DllCall("gdiplus\GdipDeleteFont", A_PtrSize ? "UPtr" : "UInt", hFont)
  2729. }
  2730.  
  2731. ;#####################################################################################
  2732.  
  2733. Gdip_DeleteStringFormat(hFormat)
  2734. {
  2735.    return DllCall("gdiplus\GdipDeleteStringFormat", A_PtrSize ? "UPtr" : "UInt", hFormat)
  2736. }
  2737.  
  2738. ;#####################################################################################
  2739.  
  2740. Gdip_DeleteFontFamily(hFamily)
  2741. {
  2742.    return DllCall("gdiplus\GdipDeleteFontFamily", A_PtrSize ? "UPtr" : "UInt", hFamily)
  2743. }
  2744.  
  2745. ;#####################################################################################
  2746.  
  2747. Gdip_DeleteMatrix(Matrix)
  2748. {
  2749.    return DllCall("gdiplus\GdipDeleteMatrix", A_PtrSize ? "UPtr" : "UInt", Matrix)
  2750. }
  2751.  
  2752. ;#####################################################################################
  2753. ; Text functions
  2754. ;#####################################################################################
  2755.  
  2756. Gdip_TextToGraphics(pGraphics, Text, Options, Font="Arial", Width="", Height="", Measure=0)
  2757. {
  2758.     IWidth := Width, IHeight:= Height
  2759.    
  2760.     RegExMatch(Options, "i)X([\-\d\.]+)(p*)", xpos)
  2761.     RegExMatch(Options, "i)Y([\-\d\.]+)(p*)", ypos)
  2762.     RegExMatch(Options, "i)W([\-\d\.]+)(p*)", Width)
  2763.     RegExMatch(Options, "i)H([\-\d\.]+)(p*)", Height)
  2764.     RegExMatch(Options, "i)C(?!(entre|enter))([a-f\d]+)", Colour)
  2765.     RegExMatch(Options, "i)Top|Up|Bottom|Down|vCentre|vCenter", vPos)
  2766.     RegExMatch(Options, "i)NoWrap", NoWrap)
  2767.     RegExMatch(Options, "i)R(\d)", Rendering)
  2768.     RegExMatch(Options, "i)S(\d+)(p*)", Size)
  2769.  
  2770.     if !Gdip_DeleteBrush(Gdip_CloneBrush(Colour2))
  2771.         PassBrush := 1, pBrush := Colour2
  2772.    
  2773.     if !(IWidth && IHeight) && (xpos2 || ypos2 || Width2 || Height2 || Size2)
  2774.         return -1
  2775.  
  2776.     Style := 0, Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout"
  2777.     Loop, Parse, Styles, |
  2778.     {
  2779.         if RegExMatch(Options, "\b" A_loopField)
  2780.         Style |= (A_LoopField != "StrikeOut") ? (A_Index-1) : 8
  2781.     }
  2782.  
  2783.     Align := 0, Alignments := "Near|Left|Centre|Center|Far|Right"
  2784.     Loop, Parse, Alignments, |
  2785.     {
  2786.         if RegExMatch(Options, "\b" A_loopField)
  2787.             Align |= A_Index//2.1      ; 0|0|1|1|2|2
  2788.     }
  2789.  
  2790.     xpos := (xpos1 != "") ? xpos2 ? IWidth*(xpos1/100) : xpos1 : 0
  2791.     ypos := (ypos1 != "") ? ypos2 ? IHeight*(ypos1/100) : ypos1 : 0
  2792.     Width := Width1 ? Width2 ? IWidth*(Width1/100) : Width1 : IWidth
  2793.     Height := Height1 ? Height2 ? IHeight*(Height1/100) : Height1 : IHeight
  2794.     if !PassBrush
  2795.         Colour := "0x" (Colour2 ? Colour2 : "ff000000")
  2796.     Rendering := ((Rendering1 >= 0) && (Rendering1 <= 5)) ? Rendering1 : 4
  2797.     Size := (Size1 > 0) ? Size2 ? IHeight*(Size1/100) : Size1 : 12
  2798.  
  2799.     hFamily := Gdip_FontFamilyCreate(Font)
  2800.     hFont := Gdip_FontCreate(hFamily, Size, Style)
  2801.     FormatStyle := NoWrap ? 0x4000 | 0x1000 : 0x4000
  2802.     hFormat := Gdip_StringFormatCreate(FormatStyle)
  2803.     pBrush := PassBrush ? pBrush : Gdip_BrushCreateSolid(Colour)
  2804.     if !(hFamily && hFont && hFormat && pBrush && pGraphics)
  2805.         return !pGraphics ? -2 : !hFamily ? -3 : !hFont ? -4 : !hFormat ? -5 : !pBrush ? -6 : 0
  2806.    
  2807.     CreateRectF(RC, xpos, ypos, Width, Height)
  2808.     Gdip_SetStringFormatAlign(hFormat, Align)
  2809.     Gdip_SetTextRenderingHint(pGraphics, Rendering)
  2810.     ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
  2811.  
  2812.     if vPos
  2813.     {
  2814.         StringSplit, ReturnRC, ReturnRC, |
  2815.        
  2816.         if (vPos = "vCentre") || (vPos = "vCenter")
  2817.             ypos += (Height-ReturnRC4)//2
  2818.         else if (vPos = "Top") || (vPos = "Up")
  2819.             ypos := 0
  2820.         else if (vPos = "Bottom") || (vPos = "Down")
  2821.             ypos := Height-ReturnRC4
  2822.        
  2823.         CreateRectF(RC, xpos, ypos, Width, ReturnRC4)
  2824.         ReturnRC := Gdip_MeasureString(pGraphics, Text, hFont, hFormat, RC)
  2825.     }
  2826.  
  2827.     if !Measure
  2828.         E := Gdip_DrawString(pGraphics, Text, hFont, hFormat, pBrush, RC)
  2829.  
  2830.     if !PassBrush
  2831.         Gdip_DeleteBrush(pBrush)
  2832.     Gdip_DeleteStringFormat(hFormat)  
  2833.     Gdip_DeleteFont(hFont)
  2834.     Gdip_DeleteFontFamily(hFamily)
  2835.     return E ? E : ReturnRC
  2836. }
  2837.  
  2838. ;#####################################################################################
  2839.  
  2840. Gdip_DrawString(pGraphics, sString, hFont, hFormat, pBrush, ByRef RectF)
  2841. {
  2842.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2843.    
  2844.     if (!A_IsUnicode)
  2845.     {
  2846.         nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, 0, "int", 0)
  2847.         VarSetCapacity(wString, nSize*2)
  2848.         DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
  2849.     }
  2850.    
  2851.     return DllCall("gdiplus\GdipDrawString"
  2852.                     , Ptr, pGraphics
  2853.                     , Ptr, A_IsUnicode ? &sString : &wString
  2854.                     , "int", -1
  2855.                     , Ptr, hFont
  2856.                     , Ptr, &RectF
  2857.                     , Ptr, hFormat
  2858.                     , Ptr, pBrush)
  2859. }
  2860.  
  2861. ;#####################################################################################
  2862.  
  2863. Gdip_MeasureString(pGraphics, sString, hFont, hFormat, ByRef RectF)
  2864. {
  2865.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2866.    
  2867.     VarSetCapacity(RC, 16)
  2868.     if !A_IsUnicode
  2869.     {
  2870.         nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, "uint", 0, "int", 0)
  2871.         VarSetCapacity(wString, nSize*2)  
  2872.         DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &sString, "int", -1, Ptr, &wString, "int", nSize)
  2873.     }
  2874.    
  2875.     DllCall("gdiplus\GdipMeasureString"
  2876.                     , Ptr, pGraphics
  2877.                     , Ptr, A_IsUnicode ? &sString : &wString
  2878.                     , "int", -1
  2879.                     , Ptr, hFont
  2880.                     , Ptr, &RectF
  2881.                     , Ptr, hFormat
  2882.                     , Ptr, &RC
  2883.                     , "uint*", Chars
  2884.                     , "uint*", Lines)
  2885.    
  2886.     return &RC ? NumGet(RC, 0, "float") "|" NumGet(RC, 4, "float") "|" NumGet(RC, 8, "float") "|" NumGet(RC, 12, "float") "|" Chars "|" Lines : 0
  2887. }
  2888.  
  2889. ; Near = 0
  2890. ; Center = 1
  2891. ; Far = 2
  2892. Gdip_SetStringFormatAlign(hFormat, Align)
  2893. {
  2894.    return DllCall("gdiplus\GdipSetStringFormatAlign", A_PtrSize ? "UPtr" : "UInt", hFormat, "int", Align)
  2895. }
  2896.  
  2897. ; StringFormatFlagsDirectionRightToLeft    = 0x00000001
  2898. ; StringFormatFlagsDirectionVertical       = 0x00000002
  2899. ; StringFormatFlagsNoFitBlackBox           = 0x00000004
  2900. ; StringFormatFlagsDisplayFormatControl    = 0x00000020
  2901. ; StringFormatFlagsNoFontFallback          = 0x00000400
  2902. ; StringFormatFlagsMeasureTrailingSpaces   = 0x00000800
  2903. ; StringFormatFlagsNoWrap                  = 0x00001000
  2904. ; StringFormatFlagsLineLimit               = 0x00002000
  2905. ; StringFormatFlagsNoClip                  = 0x00004000
  2906. Gdip_StringFormatCreate(Format=0, Lang=0)
  2907. {
  2908.    DllCall("gdiplus\GdipCreateStringFormat", "int", Format, "int", Lang, A_PtrSize ? "UPtr*" : "UInt*", hFormat)
  2909.    return hFormat
  2910. }
  2911.  
  2912. ; Regular = 0
  2913. ; Bold = 1
  2914. ; Italic = 2
  2915. ; BoldItalic = 3
  2916. ; Underline = 4
  2917. ; Strikeout = 8
  2918. Gdip_FontCreate(hFamily, Size, Style=0)
  2919. {
  2920.    DllCall("gdiplus\GdipCreateFont", A_PtrSize ? "UPtr" : "UInt", hFamily, "float", Size, "int", Style, "int", 0, A_PtrSize ? "UPtr*" : "UInt*", hFont)
  2921.    return hFont
  2922. }
  2923.  
  2924. Gdip_FontFamilyCreate(Font)
  2925. {
  2926.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2927.    
  2928.     if (!A_IsUnicode)
  2929.     {
  2930.         nSize := DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, "uint", 0, "int", 0)
  2931.         VarSetCapacity(wFont, nSize*2)
  2932.         DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, Ptr, &Font, "int", -1, Ptr, &wFont, "int", nSize)
  2933.     }
  2934.    
  2935.     DllCall("gdiplus\GdipCreateFontFamilyFromName"
  2936.                     , Ptr, A_IsUnicode ? &Font : &wFont
  2937.                     , "uint", 0
  2938.                     , A_PtrSize ? "UPtr*" : "UInt*", hFamily)
  2939.    
  2940.     return hFamily
  2941. }
  2942.  
  2943. ;#####################################################################################
  2944. ; Matrix functions
  2945. ;#####################################################################################
  2946.  
  2947. Gdip_CreateAffineMatrix(m11, m12, m21, m22, x, y)
  2948. {
  2949.    DllCall("gdiplus\GdipCreateMatrix2", "float", m11, "float", m12, "float", m21, "float", m22, "float", x, "float", y, A_PtrSize ? "UPtr*" : "UInt*", Matrix)
  2950.    return Matrix
  2951. }
  2952.  
  2953. Gdip_CreateMatrix()
  2954. {
  2955.    DllCall("gdiplus\GdipCreateMatrix", A_PtrSize ? "UPtr*" : "UInt*", Matrix)
  2956.    return Matrix
  2957. }
  2958.  
  2959. ;#####################################################################################
  2960. ; GraphicsPath functions
  2961. ;#####################################################################################
  2962.  
  2963. ; Alternate = 0
  2964. ; Winding = 1
  2965. Gdip_CreatePath(BrushMode=0)
  2966. {
  2967.     DllCall("gdiplus\GdipCreatePath", "int", BrushMode, A_PtrSize ? "UPtr*" : "UInt*", Path)
  2968.     return Path
  2969. }
  2970.  
  2971. Gdip_AddPathEllipse(Path, x, y, w, h)
  2972. {
  2973.     return DllCall("gdiplus\GdipAddPathEllipse", A_PtrSize ? "UPtr" : "UInt", Path, "float", x, "float", y, "float", w, "float", h)
  2974. }
  2975.  
  2976. Gdip_AddPathPolygon(Path, Points)
  2977. {
  2978.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  2979.    
  2980.     StringSplit, Points, Points, |
  2981.     VarSetCapacity(PointF, 8*Points0)  
  2982.     Loop, %Points0%
  2983.     {
  2984.         StringSplit, Coord, Points%A_Index%, `,
  2985.         NumPut(Coord1, PointF, 8*(A_Index-1), "float"), NumPut(Coord2, PointF, (8*(A_Index-1))+4, "float")
  2986.     }  
  2987.  
  2988.     return DllCall("gdiplus\GdipAddPathPolygon", Ptr, Path, Ptr, &PointF, "int", Points0)
  2989. }
  2990.  
  2991. Gdip_DeletePath(Path)
  2992. {
  2993.     return DllCall("gdiplus\GdipDeletePath", A_PtrSize ? "UPtr" : "UInt", Path)
  2994. }
  2995.  
  2996. ;#####################################################################################
  2997. ; Quality functions
  2998. ;#####################################################################################
  2999.  
  3000. ; SystemDefault = 0
  3001. ; SingleBitPerPixelGridFit = 1
  3002. ; SingleBitPerPixel = 2
  3003. ; AntiAliasGridFit = 3
  3004. ; AntiAlias = 4
  3005. Gdip_SetTextRenderingHint(pGraphics, RenderingHint)
  3006. {
  3007.     return DllCall("gdiplus\GdipSetTextRenderingHint", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", RenderingHint)
  3008. }
  3009.  
  3010. ; Default = 0
  3011. ; LowQuality = 1
  3012. ; HighQuality = 2
  3013. ; Bilinear = 3
  3014. ; Bicubic = 4
  3015. ; NearestNeighbor = 5
  3016. ; HighQualityBilinear = 6
  3017. ; HighQualityBicubic = 7
  3018. Gdip_SetInterpolationMode(pGraphics, InterpolationMode)
  3019. {
  3020.    return DllCall("gdiplus\GdipSetInterpolationMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", InterpolationMode)
  3021. }
  3022.  
  3023. ; Default = 0
  3024. ; HighSpeed = 1
  3025. ; HighQuality = 2
  3026. ; None = 3
  3027. ; AntiAlias = 4
  3028. Gdip_SetSmoothingMode(pGraphics, SmoothingMode)
  3029. {
  3030.    return DllCall("gdiplus\GdipSetSmoothingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", SmoothingMode)
  3031. }
  3032.  
  3033. ; CompositingModeSourceOver = 0 (blended)
  3034. ; CompositingModeSourceCopy = 1 (overwrite)
  3035. Gdip_SetCompositingMode(pGraphics, CompositingMode=0)
  3036. {
  3037.    return DllCall("gdiplus\GdipSetCompositingMode", A_PtrSize ? "UPtr" : "UInt", pGraphics, "int", CompositingMode)
  3038. }
  3039.  
  3040. ;#####################################################################################
  3041. ; Extra functions
  3042. ;#####################################################################################
  3043.  
  3044. Gdip_Startup()
  3045. {
  3046.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  3047.    
  3048.     if !DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
  3049.         DllCall("LoadLibrary", "str", "gdiplus")
  3050.     VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
  3051.     DllCall("gdiplus\GdiplusStartup", A_PtrSize ? "UPtr*" : "uint*", pToken, Ptr, &si, Ptr, 0)
  3052.     return pToken
  3053. }
  3054.  
  3055. Gdip_Shutdown(pToken)
  3056. {
  3057.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  3058.    
  3059.     DllCall("gdiplus\GdiplusShutdown", Ptr, pToken)
  3060.     if hModule := DllCall("GetModuleHandle", "str", "gdiplus", Ptr)
  3061.         DllCall("FreeLibrary", Ptr, hModule)
  3062.     return 0
  3063. }
  3064.  
  3065. ; Prepend = 0; The new operation is applied before the old operation.
  3066. ; Append = 1; The new operation is applied after the old operation.
  3067. Gdip_RotateWorldTransform(pGraphics, Angle, MatrixOrder=0)
  3068. {
  3069.     return DllCall("gdiplus\GdipRotateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", Angle, "int", MatrixOrder)
  3070. }
  3071.  
  3072. Gdip_ScaleWorldTransform(pGraphics, x, y, MatrixOrder=0)
  3073. {
  3074.     return DllCall("gdiplus\GdipScaleWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
  3075. }
  3076.  
  3077. Gdip_TranslateWorldTransform(pGraphics, x, y, MatrixOrder=0)
  3078. {
  3079.     return DllCall("gdiplus\GdipTranslateWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "int", MatrixOrder)
  3080. }
  3081.  
  3082. Gdip_ResetWorldTransform(pGraphics)
  3083. {
  3084.     return DllCall("gdiplus\GdipResetWorldTransform", A_PtrSize ? "UPtr" : "UInt", pGraphics)
  3085. }
  3086.  
  3087. Gdip_GetRotatedTranslation(Width, Height, Angle, ByRef xTranslation, ByRef yTranslation)
  3088. {
  3089.     pi := 3.14159, TAngle := Angle*(pi/180)
  3090.  
  3091.     Bound := (Angle >= 0) ? Mod(Angle, 360) : 360-Mod(-Angle, -360)
  3092.     if ((Bound >= 0) && (Bound <= 90))
  3093.         xTranslation := Height*Sin(TAngle), yTranslation := 0
  3094.     else if ((Bound > 90) && (Bound <= 180))
  3095.         xTranslation := (Height*Sin(TAngle))-(Width*Cos(TAngle)), yTranslation := -Height*Cos(TAngle)
  3096.     else if ((Bound > 180) && (Bound <= 270))
  3097.         xTranslation := -(Width*Cos(TAngle)), yTranslation := -(Height*Cos(TAngle))-(Width*Sin(TAngle))
  3098.     else if ((Bound > 270) && (Bound <= 360))
  3099.         xTranslation := 0, yTranslation := -Width*Sin(TAngle)
  3100. }
  3101.  
  3102. Gdip_GetRotatedDimensions(Width, Height, Angle, ByRef RWidth, ByRef RHeight)
  3103. {
  3104.     pi := 3.14159, TAngle := Angle*(pi/180)
  3105.     if !(Width && Height)
  3106.         return -1
  3107.     RWidth := Ceil(Abs(Width*Cos(TAngle))+Abs(Height*Sin(TAngle)))
  3108.     RHeight := Ceil(Abs(Width*Sin(TAngle))+Abs(Height*Cos(Tangle)))
  3109. }
  3110.  
  3111. ; RotateNoneFlipNone   = 0
  3112. ; Rotate90FlipNone     = 1
  3113. ; Rotate180FlipNone    = 2
  3114. ; Rotate270FlipNone    = 3
  3115. ; RotateNoneFlipX      = 4
  3116. ; Rotate90FlipX        = 5
  3117. ; Rotate180FlipX       = 6
  3118. ; Rotate270FlipX       = 7
  3119. ; RotateNoneFlipY      = Rotate180FlipX
  3120. ; Rotate90FlipY        = Rotate270FlipX
  3121. ; Rotate180FlipY       = RotateNoneFlipX
  3122. ; Rotate270FlipY       = Rotate90FlipX
  3123. ; RotateNoneFlipXY     = Rotate180FlipNone
  3124. ; Rotate90FlipXY       = Rotate270FlipNone
  3125. ; Rotate180FlipXY      = RotateNoneFlipNone
  3126. ; Rotate270FlipXY      = Rotate90FlipNone
  3127.  
  3128. Gdip_ImageRotateFlip(pBitmap, RotateFlipType=1)
  3129. {
  3130.     return DllCall("gdiplus\GdipImageRotateFlip", A_PtrSize ? "UPtr" : "UInt", pBitmap, "int", RotateFlipType)
  3131. }
  3132.  
  3133. ; Replace = 0
  3134. ; Intersect = 1
  3135. ; Union = 2
  3136. ; Xor = 3
  3137. ; Exclude = 4
  3138. ; Complement = 5
  3139. Gdip_SetClipRect(pGraphics, x, y, w, h, CombineMode=0)
  3140. {
  3141.    return DllCall("gdiplus\GdipSetClipRect",  A_PtrSize ? "UPtr" : "UInt", pGraphics, "float", x, "float", y, "float", w, "float", h, "int", CombineMode)
  3142. }
  3143.  
  3144. Gdip_SetClipPath(pGraphics, Path, CombineMode=0)
  3145. {
  3146.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  3147.     return DllCall("gdiplus\GdipSetClipPath", Ptr, pGraphics, Ptr, Path, "int", CombineMode)
  3148. }
  3149.  
  3150. Gdip_ResetClip(pGraphics)
  3151. {
  3152.    return DllCall("gdiplus\GdipResetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics)
  3153. }
  3154.  
  3155. Gdip_GetClipRegion(pGraphics)
  3156. {
  3157.     Region := Gdip_CreateRegion()
  3158.     DllCall("gdiplus\GdipGetClip", A_PtrSize ? "UPtr" : "UInt", pGraphics, "UInt*", Region)
  3159.     return Region
  3160. }
  3161.  
  3162. Gdip_SetClipRegion(pGraphics, Region, CombineMode=0)
  3163. {
  3164.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  3165.    
  3166.     return DllCall("gdiplus\GdipSetClipRegion", Ptr, pGraphics, Ptr, Region, "int", CombineMode)
  3167. }
  3168.  
  3169. Gdip_CreateRegion()
  3170. {
  3171.     DllCall("gdiplus\GdipCreateRegion", "UInt*", Region)
  3172.     return Region
  3173. }
  3174.  
  3175. Gdip_DeleteRegion(Region)
  3176. {
  3177.     return DllCall("gdiplus\GdipDeleteRegion", A_PtrSize ? "UPtr" : "UInt", Region)
  3178. }
  3179.  
  3180. ;#####################################################################################
  3181. ; BitmapLockBits
  3182. ;#####################################################################################
  3183.  
  3184. Gdip_LockBits(pBitmap, x, y, w, h, ByRef Stride, ByRef Scan0, ByRef BitmapData, LockMode = 3, PixelFormat = 0x26200a)
  3185. {
  3186.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  3187.    
  3188.     CreateRect(Rect, x, y, w, h)
  3189.     VarSetCapacity(BitmapData, 16+2*(A_PtrSize ? A_PtrSize : 4), 0)
  3190.     E := DllCall("Gdiplus\GdipBitmapLockBits", Ptr, pBitmap, Ptr, &Rect, "uint", LockMode, "int", PixelFormat, Ptr, &BitmapData)
  3191.     Stride := NumGet(BitmapData, 8, "Int")
  3192.     Scan0 := NumGet(BitmapData, 16, Ptr)
  3193.     return E
  3194. }
  3195.  
  3196. ;#####################################################################################
  3197.  
  3198. Gdip_UnlockBits(pBitmap, ByRef BitmapData)
  3199. {
  3200.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  3201.    
  3202.     return DllCall("Gdiplus\GdipBitmapUnlockBits", Ptr, pBitmap, Ptr, &BitmapData)
  3203. }
  3204.  
  3205. ;#####################################################################################
  3206.  
  3207. Gdip_SetLockBitPixel(ARGB, Scan0, x, y, Stride)
  3208. {
  3209.     Numput(ARGB, Scan0+0, (x*4)+(y*Stride), "UInt")
  3210. }
  3211.  
  3212. ;#####################################################################################
  3213.  
  3214. Gdip_GetLockBitPixel(Scan0, x, y, Stride)
  3215. {
  3216.     return NumGet(Scan0+0, (x*4)+(y*Stride), "UInt")
  3217. }
  3218.  
  3219. ;#####################################################################################
  3220.  
  3221. Gdip_PixelateBitmap(pBitmap, ByRef pBitmapOut, BlockSize)
  3222. {
  3223.     static PixelateBitmap
  3224.    
  3225.     Ptr := A_PtrSize ? "UPtr" : "UInt"
  3226.    
  3227.     if (!PixelateBitmap)
  3228.     {
  3229.         if A_PtrSize != 8 ; x86 machine code
  3230.         MCode_PixelateBitmap =
  3231.         (LTrim Join
  3232.         558BEC83EC3C8B4514538B5D1C99F7FB56578BC88955EC894DD885C90F8E830200008B451099F7FB8365DC008365E000894DC88955F08945E833FF897DD4
  3233.         397DE80F8E160100008BCB0FAFCB894DCC33C08945F88945FC89451C8945143BD87E608B45088D50028BC82BCA8BF02BF2418945F48B45E02955F4894DC4
  3234.         8D0CB80FAFCB03CA895DD08BD1895DE40FB64416030145140FB60201451C8B45C40FB604100145FC8B45F40FB604020145F883C204FF4DE475D6034D18FF
  3235.         4DD075C98B4DCC8B451499F7F98945148B451C99F7F989451C8B45FC99F7F98945FC8B45F899F7F98945F885DB7E648B450C8D50028BC82BCA83C103894D
  3236.         C48BC82BCA41894DF48B4DD48945E48B45E02955E48D0C880FAFCB03CA895DD08BD18BF38A45148B7DC48804178A451C8B7DF488028A45FC8804178A45F8
  3237.         8B7DE488043A83C2044E75DA034D18FF4DD075CE8B4DCC8B7DD447897DD43B7DE80F8CF2FEFFFF837DF0000F842C01000033C08945F88945FC89451C8945
  3238.         148945E43BD87E65837DF0007E578B4DDC034DE48B75E80FAF4D180FAFF38B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945CC0F
  3239.         B6440E030145140FB60101451C0FB6440F010145FC8B45F40FB604010145F883C104FF4DCC75D8FF45E4395DE47C9B8B4DF00FAFCB85C9740B8B451499F7
  3240.         F9894514EB048365140033F63BCE740B8B451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB
  3241.         038975F88975E43BDE7E5A837DF0007E4C8B4DDC034DE48B75E80FAF4D180FAFF38B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955CC8A55
  3242.         1488540E038A551C88118A55FC88540F018A55F888140183C104FF4DCC75DFFF45E4395DE47CA68B45180145E0015DDCFF4DC80F8594FDFFFF8B451099F7
  3243.         FB8955F08945E885C00F8E450100008B45EC0FAFC38365DC008945D48B45E88945CC33C08945F88945FC89451C8945148945103945EC7E6085DB7E518B4D
  3244.         D88B45080FAFCB034D108D50020FAF4D18034DDC8BF08BF88945F403CA2BF22BFA2955F4895DC80FB6440E030145140FB60101451C0FB6440F010145FC8B
  3245.         45F40FB604080145F883C104FF4DC875D8FF45108B45103B45EC7CA08B4DD485C9740B8B451499F7F9894514EB048365140033F63BCE740B8B451C99F7F9
  3246.         89451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975103975EC7E5585DB7E468B4DD88B450C
  3247.         0FAFCB034D108D50020FAF4D18034DDC8BF08BF803CA2BF22BFA2BC2895DC88A551488540E038A551C88118A55FC88540F018A55F888140183C104FF4DC8
  3248.         75DFFF45108B45103B45EC7CAB8BC3C1E0020145DCFF4DCC0F85CEFEFFFF8B4DEC33C08945F88945FC89451C8945148945103BC87E6C3945F07E5C8B4DD8
  3249.         8B75E80FAFCB034D100FAFF30FAF4D188B45088D500203CA8D0CB18BF08BF88945F48B45F02BF22BFA2955F48945C80FB6440E030145140FB60101451C0F
  3250.         B6440F010145FC8B45F40FB604010145F883C104FF4DC875D833C0FF45108B4DEC394D107C940FAF4DF03BC874068B451499F7F933F68945143BCE740B8B
  3251.         451C99F7F989451CEB0389751C3BCE740B8B45FC99F7F98945FCEB038975FC3BCE740B8B45F899F7F98945F8EB038975F88975083975EC7E63EB0233F639
  3252.         75F07E4F8B4DD88B75E80FAFCB034D080FAFF30FAF4D188B450C8D500203CA8D0CB18BF08BF82BF22BFA2BC28B55F08955108A551488540E038A551C8811
  3253.         8A55FC88540F018A55F888140883C104FF4D1075DFFF45088B45083B45EC7C9F5F5E33C05BC9C21800
  3254.         )
  3255.         else ; x64 machine code
  3256.         MCode_PixelateBitmap =
  3257.         (LTrim Join
  3258.         4489442418488954241048894C24085355565741544155415641574883EC28418BC1448B8C24980000004C8BDA99488BD941F7F9448BD0448BFA8954240C
  3259.         448994248800000085C00F8E9D020000418BC04533E4458BF299448924244C8954241041F7F933C9898C24980000008BEA89542404448BE889442408EB05
  3260.         4C8B5C24784585ED0F8E1A010000458BF1418BFD48897C2418450FAFF14533D233F633ED4533E44533ED4585C97E5B4C63BC2490000000418D040A410FAF
  3261.         C148984C8D441802498BD9498BD04D8BD90FB642010FB64AFF4403E80FB60203E90FB64AFE4883C2044403E003F149FFCB75DE4D03C748FFCB75D0488B7C
  3262.         24188B8C24980000004C8B5C2478418BC59941F7FE448BE8418BC49941F7FE448BE08BC59941F7FE8BE88BC69941F7FE8BF04585C97E4048639C24900000
  3263.         004103CA4D8BC1410FAFC94863C94A8D541902488BCA498BC144886901448821408869FF408871FE4883C10448FFC875E84803D349FFC875DA8B8C249800
  3264.         0000488B5C24704C8B5C24784183C20448FFCF48897C24180F850AFFFFFF8B6C2404448B2424448B6C24084C8B74241085ED0F840A01000033FF33DB4533
  3265.         DB4533D24533C04585C97E53488B74247085ED7E42438D0C04418BC50FAF8C2490000000410FAFC18D04814863C8488D5431028BCD0FB642014403D00FB6
  3266.         024883C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC17CB28BCD410FAFC985C9740A418BC299F7F98BF0EB0233F685C9740B418BC3
  3267.         99F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585C97E4D4C8B74247885ED7E3841
  3268.         8D0C14418BC50FAF8C2490000000410FAFC18D04814863C84A8D4431028BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2413BD17CBD
  3269.         4C8B7424108B8C2498000000038C2490000000488B5C24704503E149FFCE44892424898C24980000004C897424100F859EFDFFFF448B7C240C448B842480
  3270.         000000418BC09941F7F98BE8448BEA89942498000000896C240C85C00F8E3B010000448BAC2488000000418BCF448BF5410FAFC9898C248000000033FF33
  3271.         ED33F64533DB4533D24533C04585FF7E524585C97E40418BC5410FAFC14103C00FAF84249000000003C74898488D541802498BD90FB642014403D00FB602
  3272.         4883C2044403D80FB642FB03F00FB642FA03E848FFCB75DE488B5C247041FFC0453BC77CAE85C9740B418BC299F7F9448BE0EB034533E485C9740A418BC3
  3273.         99F7F98BD8EB0233DB85C9740A8BC699F7F9448BD8EB034533DB85C9740A8BC599F7F9448BD0EB034533D24533C04585FF7E4E488B4C24784585C97E3541
  3274.         8BC5410FAFC14103C00FAF84249000000003C74898488D540802498BC144886201881A44885AFF448852FE4883C20448FFC875E941FFC0453BC77CBE8B8C
  3275.         2480000000488B5C2470418BC1C1E00203F849FFCE0F85ECFEFFFF448BAC24980000008B6C240C448BA4248800000033FF33DB4533DB4533D24533C04585
  3276.         FF7E5A488B7424704585ED7E48418BCC8BC5410FAFC94103C80FAF8C2490000000410FAFC18D04814863C8488D543102418BCD0FB642014403D00FB60248
  3277.         83C2044403D80FB642FB03D80FB642FA03F848FFC975DE41FFC0453BC77CAB418BCF410FAFCD85C9740A418BC299F7F98BF0EB0233F685C9740B418BC399
  3278.         F7F9448BD8EB034533DB85C9740A8BC399F7F9448BD0EB034533D285C9740A8BC799F7F9448BC0EB034533C033D24585FF7E4E4585ED7E42418BCC8BC541
  3279.         0FAFC903CA0FAF8C2490000000410FAFC18D04814863C8488B442478488D440102418BCD40887001448818448850FF448840FE4883C00448FFC975E8FFC2
  3280.         413BD77CB233C04883C428415F415E415D415C5F5E5D5BC3
  3281.         )
  3282.        
  3283.         VarSetCapacity(PixelateBitmap, StrLen(MCode_PixelateBitmap)//2)
  3284.         Loop % StrLen(MCode_PixelateBitmap)//2      ;%
  3285.             NumPut("0x" SubStr(MCode_PixelateBitmap, (2*A_Index)-1, 2), PixelateBitmap, A_Index-1, "UChar")
  3286.         DllCall("VirtualProtect", Ptr, &PixelateBitmap, Ptr, VarSetCapacity(PixelateBitmap), "uint", 0x40, A_PtrSize ? "UPtr*" : "UInt*", 0)
  3287.     }
  3288.  
  3289.     Gdip_GetImageDimensions(pBitmap, Width, Height)
  3290.    
  3291.     if (Width != Gdip_GetImageWidth(pBitmapOut) || Height != Gdip_GetImageHeight(pBitmapOut))
  3292.         return -1
  3293.     if (BlockSize > Width || BlockSize > Height)
  3294.         return -2
  3295.  
  3296.     E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1)
  3297.     E2 := Gdip_LockBits(pBitmapOut, 0, 0, Width, Height, Stride2, Scan02, BitmapData2)
  3298.     if (E1 || E2)
  3299.         return -3
  3300.  
  3301.     E := DllCall(&PixelateBitmap, Ptr, Scan01, Ptr, Scan02, "int", Width, "int", Height, "int", Stride1, "int", BlockSize)
  3302.    
  3303.     Gdip_UnlockBits(pBitmap, BitmapData1), Gdip_UnlockBits(pBitmapOut, BitmapData2)
  3304.     return 0
  3305. }
  3306.  
  3307. ;#####################################################################################
  3308.  
  3309. Gdip_ToARGB(A, R, G, B)
  3310. {
  3311.     return (A << 24) | (R << 16) | (G << 8) | B
  3312. }
  3313.  
  3314. ;#####################################################################################
  3315.  
  3316. Gdip_FromARGB(ARGB, ByRef A, ByRef R, ByRef G, ByRef B)
  3317. {
  3318.     A := (0xff000000 & ARGB) >> 24
  3319.     R := (0x00ff0000 & ARGB) >> 16
  3320.     G := (0x0000ff00 & ARGB) >> 8
  3321.     B := 0x000000ff & ARGB
  3322. }
  3323.  
  3324. ;#####################################################################################
  3325.  
  3326. Gdip_AFromARGB(ARGB)
  3327. {
  3328.     return (0xff000000 & ARGB) >> 24
  3329. }
  3330.  
  3331. ;#####################################################################################
  3332.  
  3333. Gdip_RFromARGB(ARGB)
  3334. {
  3335.     return (0x00ff0000 & ARGB) >> 16
  3336. }
  3337.  
  3338. ;#####################################################################################
  3339.  
  3340. Gdip_GFromARGB(ARGB)
  3341. {
  3342.     return (0x0000ff00 & ARGB) >> 8
  3343. }
  3344.  
  3345. ;#####################################################################################
  3346.  
  3347. Gdip_BFromARGB(ARGB)
  3348. {
  3349.     return 0x000000ff & ARGB
  3350. }
  3351.  
  3352. ;#####################################################################################
  3353.  
  3354. StrGetB(Address, Length=-1, Encoding=0)
  3355. {
  3356.     ; Flexible parameter handling:
  3357.     if Length is not integer
  3358.     Encoding := Length,  Length := -1
  3359.  
  3360.     ; Check for obvious errors.
  3361.     if (Address+0 < 1024)
  3362.         return
  3363.  
  3364.     ; Ensure 'Encoding' contains a numeric identifier.
  3365.     if Encoding = UTF-16
  3366.         Encoding = 1200
  3367.     else if Encoding = UTF-8
  3368.         Encoding = 65001
  3369.     else if SubStr(Encoding,1,2)="CP"
  3370.         Encoding := SubStr(Encoding,3)
  3371.  
  3372.     if !Encoding ; "" or 0
  3373.     {
  3374.         ; No conversion necessary, but we might not want the whole string.
  3375.         if (Length == -1)
  3376.             Length := DllCall("lstrlen", "uint", Address)
  3377.         VarSetCapacity(String, Length)
  3378.         DllCall("lstrcpyn", "str", String, "uint", Address, "int", Length + 1)
  3379.     }
  3380.     else if Encoding = 1200 ; UTF-16
  3381.     {
  3382.         char_count := DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "uint", 0, "uint", 0, "uint", 0, "uint", 0)
  3383.         VarSetCapacity(String, char_count)
  3384.         DllCall("WideCharToMultiByte", "uint", 0, "uint", 0x400, "uint", Address, "int", Length, "str", String, "int", char_count, "uint", 0, "uint", 0)
  3385.     }
  3386.     else if Encoding is integer
  3387.     {
  3388.         ; Convert from target encoding to UTF-16 then to the active code page.
  3389.         char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", 0, "int", 0)
  3390.         VarSetCapacity(String, char_count * 2)
  3391.         char_count := DllCall("MultiByteToWideChar", "uint", Encoding, "uint", 0, "uint", Address, "int", Length, "uint", &String, "int", char_count * 2)
  3392.         String := StrGetB(&String, char_count, 1200)
  3393.     }
  3394.    
  3395.     return String
  3396. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement