AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Gdip DisposeBitmap issue
PostPosted: September 30th, 2011, 2:46 am 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
This piece of code serves to be a simple img browser (to be merged with some other code hence empty client space at the top of the GUI)....

Note: Requires Gdip.ahk

The script currently consumes about 5K of ram after it's loaded images, but keeps consuming more as the gui is resized due to some Bitmaps not being disposed. Dispose of them and the script does not work correctly, even after the bitmap has been set to the control. See commented lines starting at line 435. Uncomment those lines to reproduce the image issue (but fix the memory leak).

How to use the script:

Run the script
Drag some images onto the gui(more than 16 is best :-) )
Press F9 to reload the script

Thanks for any help and insight to this issue.

Find a screen shot here http://www.autohotkey.net/~invalid_user/RL3ScnShot.jpg
Code:
;ImgHandler Funcs
SetTitleMatchMode, 3
SetBatchLines, -1

PictureDataFields =
(LTrim Join|
ImgUNID
File Name
Name
Description
Date Added
Added By
Date Taken
VectorList
)
VectorDataFields =
(LTrim Join,
VectUNID
PointerType(MSMS/MSM/PN/None or Other?)
Pointer
AreaString
VectorName
VectorDescription
OutLineColor
)

IfNotExist %A_ScriptDir%\Data\Imgs
{
   FileCreateDir, %A_ScriptDir%\Data\Imgs
}
ScriptTitle = RepairLog 3
CurrentTab = Pictures
Padding = 20
CurPageNum =1
ImgMode = Browse

if !(GDIPToken := Gdip_Startup())
{
   Msgbox, 48, Error Occurred. I will Exit.
   ExitApp
}

Gui, Color, Black
Gui, Font, Q5
Gui, +Resize
Gui, Font, S14 CDefault, Calibri
Gui, Font, S12 CBlack, Calibri
Gui, Add, Edit, vPicItem2Desc x32 y210 w180 h190 , PhotoDescription
Gui, Font, S12 CWhite, Calibri
Gui, Add, GroupBox, vPicGrpBox x22 y130 w200 h320 , About This Photo

Gui, Add, Text, vPicItem1 x32 y150 w180 h20 , Taken On:
Gui, Add, Text, vPicItem1Desc x32 y170 w180 h20 , DATETAKENON
Gui, Add, Text, vPicItem2 x32 y190 w180 h20 , Description:

Gui, Add, Picture, vPicEdit x72 y410 w100 h30 , %A_ScriptDir%\IMGS\EditSm.png
Gui, Add, Picture, vPicAdd x72 y460 w100 h30 , %A_ScriptDir%\IMGS\Add.png
Gui, Add, Picture, vPicDelete x72 y500 w100 h30 , %A_ScriptDir%\IMGS\DeleteSm.png
Gui, Add, Picture, vPicMagnifiy x72 y540 w100 h30 , %A_ScriptDir%\IMGS\Magnify.png
Gui, Add, Picture, vPicIn x32 y580 w80 h30 , %A_ScriptDir%\IMGS\In.png
Gui, Add, Picture, vPicOut x132 y580 w80 h30 , %A_ScriptDir%\IMGS\Out.png
Gui, Add, Picture, vPicBack gPicBack x32 y620 w80 h30 , %A_ScriptDir%\IMGS\Back.png
Gui, Add, Picture, vPicNext gPicNext x132 y620 w80 h30 , %A_ScriptDir%\IMGS\Next.png
Gui, Add, Picture, vPicBrowse gPicBrowse x242 y130 w100 h30 , %A_ScriptDir%\IMGS\Browse.png
Gui, Add, Picture, vPicExplore gPicExplore x342 y130 w100 h30 , %A_ScriptDir%\IMGS\Explore.png
Gui, Add, Picture, vPicPurchase x442 y130 w100 h30 , %A_ScriptDir%\IMGS\Purchase.png
Gui, Add, Picture, vPicReadUp g x542 y130 w100 h30 , %A_ScriptDir%\IMGS\ReadUp.png
;Gui, Add, Picture, vPicImgLarge x242 y170 w850 , C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg
Gui, Add, CheckBox, vPicEditMode x652 y130 w100 h30 , Edit Mode
;Gui, 1:Add, ListView, vPicListView cwhite backgroundBlack x242 y170 w890 h560 +Icon -multi, %PictureDataFields%
Img_CreatePageIndex("242","170","900","750","20")
Gui, 1: Show, restore center, %ScriptTitle%


;Load the whole list and load it to ImgIndex
UNIDList := Pic_ReadImgUNIDList()
SetUnigNumArray(CompImgUNIDList)
Pic_LoadIndex(UNIDLIST)
Img_LoadBitMaps()
Img_ResizeMatrix()
Return
;++++++++++++++++++++++
PicBack:
If ImgMode = Browse
{
   If CurPageNum = 1
      Return
   Else
   {
      CurPageNum--
      Img_LoadBitMaps()
      Img_ResizeMatrix()
   }
}
If ImgMode = Explore
{
   If CurImgIndex = 1
   {
      ;There are no more images in the loaded index
      Return
   }
   CurImgIndex--
   CurImgUNID := ImgIndexUNID_%CurImgIndex%
   Img_Select(CurImgUNID)
   Img_LoadMainBitMap()
   Img_ResizeMain()
}
Return
;+++++++++++++++++++++
PicNext:
If ImgMode = Browse
{
   If (CurPageNum + 1 > PageMaxIndex) ;No imgs on next page
      Return
   CurPageNum++
   Img_LoadBitMaps()
   Img_ResizeMatrix()
}
If ImgMode = Explore
{
   If (CurImgIndex + 1 > ImgIndex_0)
   {
      ;There are no more images in the loaded index
      Return
   }
   CurImgIndex++
   CurImgUNID := ImgIndexUNID_%CurImgIndex%
   Img_Select(CurImgUNID)
   Img_LoadMainBitMap()
   Img_ResizeMain()
}
Return
;++++++++++++++++++++++
PicBrowse:
ImgMode = Browse
GuiControl 1:Hide, MainImgCtrl
Img_ShowMatrix()
Return
;+++++++++++++++++++++++++++
PicExplore:
ImgMode = Explore
Img_HideMatrix()

;if no img is selected
If CurImgUNID =
{
   Return
}
Img_LoadMainBitMap()

GuiControl, 1:Show, MainImgCtrl
Return
;++++++++++++++++++++++++++++++++++++++++++++
GuiDropFiles:
If CurrentTab = Pictures
{
   Loop, Parse, A_GuiEvent, `n
   {
      Pic_CreateProfile(A_LoopField)
   }
}
Return
;##############################################
GuiSize:
LastGuiW := A_GuiWidth
LastGuiH := A_GuiHeight
Img_ResizeMatrix()
Img_LoadMainBitMap()
Img_ResizeMain()
Return
;________________________________________________
ImgLabel:
;Get the unid from array
StringSplit, CtrlArray, A_GuiControl, _
;MsgBox %CtrlArray2%
CurImgIndex := CtrlArray2 + (CurPageNum * 16 - 16)
CurImgUNID := ImgIndexUNID_%CurImgIndex%

;MsgBox %CurImgUNID% || %CtrlArray2%

If A_GuiControlEvent = Normal
{
   Img_Select(CurImgUNID)
}
If A_GuiControlEvent = DoubleClick
{
   ImgMode = Explore
   Img_HideMatrix()
   Img_LoadMainBitMap()
   Img_ResizeMain()
   GuiControl, 1:Show, MainImgCtrl
}
Return
;+++++++++++++++++++++++++++++++++++
Img_LoadMainBitMap()
{
   Global
   ;Get the total Client area
   PicGetTotalClientSize(TotalCliW,TotalCliH)
   
   CurImgFile := Pic_ReadProfileElem(CurImgUNID,"File Name")
   
   CurImgPath = %A_ScriptDir%\Data\Imgs\%CurImgFile%
   If CurImgFile =
   {
      CurImgPath = %A_ScriptDir%\Data\Imgs\
   }
   ;IfExist, %ImgPath%
   ;   MsgBox %ImgPath%
   pMainBitMap := Gdip_CreateBitmapFromFile(CurImgPath)
   ImgGetDimension(CurImgPath,CurMyImgW,CurMyImgH)
}
;+++++++++++++++++++++++++++++++++++
Img_ResizeMain()
{
   Global
   ;Scale for image
   wscale := TotalCliW / CurMyimgW
   hscale := TotalCliH / CurMyimgH
   
   ;MsgBox  Img:%ImgPath% `nTotalClientW:%TotalCliW%`nTotalClientH:%TotalCliH% `nMyImgW:%MyImgW%`nMyImgH:%MyImgH%`nXOff:%Img_XOffSet%`nYOff:%Img_YOffset%`n`nW scale:%wscale%`nH Scale:%hscale%`n`nFile:%ImgFile%`nID:%CurImgUNID%
   
   Gdip_ShowImgonGui(pMainBitMap, "MainImgCtrl", ImgPath, wscale, hscale)
   Img_ResizeControl("MainImgCtrl", ImgPath, TotalCliW-20, TotalCliH-20, CurMyImgW, CurMyImgH, "242", "170")
   Gdip_DisposeImage(pMainBitMap)
   Return
}
;+++++++++++++++++++++++++++++++++++
Img_LoadBitMaps()
{
   Global
   ;Load images
   Loop, 16
   {
      Gdip_DisposeImage(pBitMap_%A_Index%)
      ImgIndexNum := A_Index + (CurPageNum * 16 - 16)
      ;Get the current image dims
      ImgFile := ImgIndex_%ImgIndexNum%
      ;MsgBox %ImgIndexNum%
      ImgPath = %A_ScriptDir%\Data\Imgs\Sm%ImgFile%
      If ImgFile =
      {
         ImgPath = %A_ScriptDir%\Data\Imgs\
      }
      ;MsgBox %ImgPath%
      pBitMap_%A_Index% := Gdip_CreateBitmapFromFile(ImgPath)
   }
   Return
}
;+++++++++++++++++++++++++++++++++++
Img_Select(ImgUNID)
{
   Global PictureDataFields
   Loop, Parse, PictureDataFields, |
   {
      ElemCont := Pic_ReadProfileElem(ImgUNID,A_LoopField)   
      If A_LoopField = Description
         GuiControl, 1:, PicItem2Desc, %ElemCont%
      If A_LoopField = Date Added
         GuiControl, 1:, PicItem1Desc, %ElemCont%
   }
   Return
}
;++++++++++++++++++++++++++++++++++++++++++++++++++
Img_HideMatrix()
{
   Loop, 16
   {
      GuiControl, Hide, ImgCtrl_%A_Index%
   }
   Return
}
;+++++++++++++++++++++++++++++++++++++++++++++++++
Img_ShowMatrix()
{
   Loop, 16
   {
      GuiControl, Show, ImgCtrl_%A_Index%
   }
   Return
}
;+++++++++++++++++++++++++++++++++++++++++++++++++++
;Pass filename with extention
Img_DownSize(FileName)
{
   FilePath = %A_ScriptDir%\Data\Imgs\%FileName%
   
   GuiW = 256
   GuiH = 256
   
   ;Get the file to convert from file - Determine W/H
   pBitmap := Gdip_CreateBitmapFromFile(FilePath)
   ImgW :=  Gdip_GetImageWidth(pBitmap)
   ImgH := Gdip_GetImageHeight(pBitmap)
   
   ;Calc resize dims
;--------------
   PicRatio := round(imgW/imgH, 5)
   GuiRatio := round(GuiW/GuiH, 5)
   if (imgW <= GuiW) && (imgH <= GuiH)
   {
      ResizedW := imgW
      ResizedH := imgH
   }
   else if (PicRatio > GuiRatio)
   {
      ResizedW := GuiW
      ResizedH := Round(ResizedW / PicRatio, 5)
   }
   else
   {
      ResizedH := (imgH >= GuiH) ? GuiH : imgH         
      ResizedW := Round(ResizedH * PicRatio, 5)
   }
;---------------
   ;MsgBox %ResizedW% %ResizedH%
   ;Create the bitmap to put resized in
   pBitmapResized := Gdip_CreateBitmap(ResizedW,ResizedH)
   ;Create a graphic from the new pBitmap
   Gnew := Gdip_GraphicsFromImage(pBitmapResized)
   ;Set interpolation
   Gdip_SetInterpolationMode(Gnew, 2)
   ;Draw resized bitmap in graphic space
   Gdip_DrawImage(Gnew, pBitmap, 0, 0,ResizedW,ResizedH)
   
   ;MsgBox %FileName%
   NewFilePath = %A_ScriptDir%\Data\Imgs\Sm%FileName%
   IfExist, %NewFilePath%
   {
      MsgBox, Error! `n`n%NewFilePath% already exists
      Exit
   }
   ;Save to disk
   Gdip_SaveBitmapToFile(pBitmapResized, NewFilePath)
   Gdip_DeleteGraphics(GNew), Gdip_DisposeImage(pBitmapResized)
   Return
}
;+++++++++++++++++++++++++++++++++++++++++++
Img_ResizeMatrix()
{
   Global
   ;Padding, CurPageNum
   ;Get the total Client area
   PicGetTotalClientSize(TotalCliW,TotalCliH)
   CliW := TotalCliW
   CliH := TotalCliH
   ;Get the imgs max cli area
   PicGetClientSize(CliW,CliH)

   Img_Xcnt = 4
   Img_Ycnt = 4
   
   Img_XOffset = 242
   Img_YOffset = 170
   Img_CntIndex = 1
   Loop, %Img_Xcnt%
   {
      Loop, %Img_Ycnt%
      {
         ;next line bugger
         ImgIndexNum := Img_CntIndex + (CurPageNum * 16 - 16)
         ;ImgIndexNum := Img_CntIndex
         ;Get the current image dims
         ImgFile := ImgIndex_%ImgIndexNum%
         ImgPath = %A_ScriptDir%\Data\Imgs\Sm%ImgFile%
         If ImgFile =
         {
            ImgPath = %A_ScriptDir%\Data\Imgs\
         }
         ImgGetDimension(ImgPath,MyImgW,MyImgH)
         
         ;Scale for image
         wscale := CliW / MyimgW ;1/1Ratio
         hscale := CliH / MyimgH
         
         ThisControlName = ImgCtrl_%Img_CntIndex%
         
         ;MsgBox Ctrl:%ThisControlName% `n Img:%ImgPath% `nTotalClientW:%TotalCliW% `nTotalClientH:%TotalCliH%`nMyImgW:%MyImgW% `nMyImgH:%MyImgH% `nXOff:%Img_XOffSet%`nYOff:%Img_YOffset%`n `nW scale:%wscale%`nH Scale:%hscale%
         
         ;Rezise the imgcontrol
         ;MsgBox % pBitmap_%Img_CntIndex%
         ThispBitmap := pBitmap_%Img_CntIndex%
         Gdip_ShowImgonGui( ThispBitmap, ThisControlName, ImgPath, wscale, hscale)
         Img_ResizeControl(ThisControlName, ImgPath, CliW, CliH, MyImgW, MyImgH, Img_XOffSet, Img_YOffset)
         Img_XOffset := Img_XOffset + Padding + CliW
         Img_CntIndex++
      }
      Img_XOffset := 242
      Img_YOffset := Img_YOffset + Padding + CliH
   }
   Return
}
;+++++++++++++++++++++++++++++++++++++++++
Img_ResizeControl(control, ImgPath, GuiW, GuiH, ImgW, ImgH, XOffSet, YOffset)
{
   PicRatio := round(imgW/imgH, 5)
   GuiRatio := round(GuiW/GuiH, 5)
   if (imgW <= GuiW) && (imgH <= GuiH)
   {
      ResizedW := imgW
      ResizedH := imgH
   }
   Else if (PicRatio > GuiRatio) ;should be else if
   {
      ResizedW := GuiW
      ResizedH := Round(ResizedW / PicRatio, 5)
   }
   else
   {
      ResizedH := (imgH >= GuiH) ? GuiH : imgH         ;set the maximum picture height to the original height
      ResizedW := Round(ResizedH * PicRatio, 5)
   }
   ;MsgBox W:%ResizedW% H:%ResizedH%
   GuiControl, 1:MoveDraw, %control%, % "w" . ResizedW . " h" . ResizedH . " x" . (GuiW - ResizedW )/2+XOffset . " y" . (GuiH - ResizedH)/2+YOffset
   return
}
;+++++++++++++++++++++++++++++++++++++++++++++++++++++
ImgGetDimension(imgpath, ByRef w, ByRef h)
{
   global GDIPToken
   IfNotExist, %imgpath%
      Return False
   Else
   {                                   
      pBM := Gdip_CreateBitmapFromFile(imgpath)                      
      w := Gdip_GetImageWidth( pBM )
      h := Gdip_GetImageHeight( pBM )                           
      Gdip_DisposeImage( pBM )                                         
      Return True
   }
}
;+++++++++++++++++++
Gdip_ShowImgonGui(pBitmap, GuiVariable, imgfile, wscale=1, hscale=1)
{
   ;pBitmap := Gdip_CreateBitmapFromFile(imgfile)
   ;Global
   If !pBitmap
      Return False
   GuiControlGet, hwnd_control, hwnd, %GuiVariable%
   If ErrorLevel
      Return False
   Width := Gdip_GetImageWidth(pBitmap)     
   Height := Gdip_GetImageHeight(pBitmap)   

   pBitmap2 := Gdip_CreateBitmap(Width * wscale, Height * hscale)
   G2 := Gdip_GraphicsFromImage(pBitmap2)
   Gdip_DrawImage(G2, pBitmap, 0, 0, Width * wscale, Height * hscale, 0, 0, Width, Height)
   Gdip_SetInterpolationMode(G2, 7)
   Gdip_SetSmoothingMode(G2, 7)

   hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap2)
   SetImage(hwnd_control, hBitmap)

   ;Gdip_DeleteGraphics(G)
   ;Gdip_DisposeImage(pBitmap)
   ;DeleteObject(hBitmap)
    ;Gdip_DeleteGraphics(G2)
   ;Gdip_DisposeImage(pBitmap2)

   Return hwnd_control
}
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PicGetTotalClientSize(ByRef w, ByRef h)
{
    Global LastGuiW, LastGuiH
   W := LastGuiW - 242
   H := LastGuiH - 170
   Return
}
;=================================================================
PicGetClientSize(ByRef w, ByRef h)
{
   Global Padding
   W := W / 4 - Padding
   H := H / 4 - Padding
   Return
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Pic_LoadIndex(ImgUNIDLIST)
{
   Global
   ImgPageIndex = 1
    ;Clear array
    Loop, %ImgIndex_0%
    {
       ImgIndex_%A_Index% =
        Gdip_DisposeImage(pBitmap_%A_Index%)
    }
   Loop, Parse, ImgUNIDList, `,
   {
      ImgFile := Pic_ReadProfileElem(A_LoopField,"File Name")
      ;Create img index
      ;MsgBox %ImgFile%
      ImgIndex_%A_Index% := ImgFile
      ;Create UNID index
      ImgIndexUNID_%A_Index% := A_LoopField
      
      ImgIndex_0++
   }
   ;Declare the max number of pages
   PageMaxIndex := ImgIndex_0 / 16
   PageMaxIndex := Ceil(PageMaxIndex)
   Return
}
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Pic_CreateProfile(FileFullPath) ; Creates a Picture profile
{
   Global CompImgIdList, PictureDataFields
   ;MsgBox %FileFullPath%
   ;Generate ID
   ImgUNID := RandomUniqNum("CompImgIDList")
   ;MsgBox %ImgUNID%
   ImgUNIDList := Pic_ReadImgUNIDList()
   ;Add to list
   ImgUNIDList := ListAdd(ImgUNID,ImgUNIDList)
   ;WriteList
   Pic_WriteImgUNIDList(ImgUNIDList)
   
   SplitPath, FileFullPath, FileName, , ,
   FileCopy, %FileFullPath%, %A_ScriptDir%\Data\Imgs\%FileName%
   Sleep, 200
   Img_DownSize(FileName)
   ;Img_CreateIconFromFile(FileFullPath)
   Loop, Parse, PictureDataFields, |
   {
      Cont =
      If A_LoopField = ImgUNID
         Cont := ImgUNID
      If A_LoopField = File Name
         Cont := FileName
      Pic_WriteProfileElem(ImgUNID,A_LoopField,Cont)
   }
   Return
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Img_CreatePageIndex(x,y,w,h,padding) ;Create gui and index arrays for images here
{
   Global
   Img_Xcnt = 4
   Img_Ycnt = 4
   ImgW := W / 4 - (Padding * Img_Xcnt - Padding)
   ImgH := H / 4 - (Padding * Img_Ycnt - Padding)
   Img_Xindex := x
   Img_Yindex := y
   Img_CntIndex = 1
   Loop, %Img_Xcnt%
   {
      Loop, %Img_Ycnt%
      {
         Gui, 1:Add, Picture, gImgLabel HwndImgCtrlHwnd%Img_CntIndex% vImgCtrl_%Img_CntIndex% x%Img_Xindex% y%Img_Yindex% w%ImgW% h%ImgH% Border, %A_ScriptDir%\IMGS\LoginImg.jpg
         Img_XIndex := Img_Xindex + Padding + ImgW
         Img_CntIndex++
      }
      Img_XIndex := x
      Img_yIndex := Img_Yindex + Padding + ImgH
   }
   ;Create the main img control
   Gui, 1:Add, Picture, HwndMainImgHwnd vMainImgCtrl w0 h0 x-1000 y-1000 Border, %A_ScriptDir%\IMGS\LoginImg.jpg
   GuiControl, 1:Hide, MainImgCtrl
   Return
}
;_______________________________________________________________
Pic_ReadImgUNIDList()
{
   IniRead, CompImgIDList, %A_ScriptDir%\Data\Pictures.ini, CompImgIDList, CompImgIDList
   If CompImgIDList = Error
      CompImgIDList =
   Return CompImgIDList
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++
Pic_WriteImgUNIDList(List)
{
   IniWrite, %List%, %A_ScriptDir%\Data\Pictures.ini, CompImgIDList, CompImgIDList
   Return
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++
Pic_WriteProfileElem(UNID,Elem,Cont)
{
   IniWrite, % Cont, %A_ScriptDir%\Data\Pictures.ini, %UNID%, %Elem%
   Return
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++
Pic_ReadProfileElem(UNID,Elem)
{
   IniRead, Cont, %A_ScriptDir%\Data\Pictures.ini, %UNID%, %Elem%
   If Cont = Error
      Cont =
   Return Cont
}
;~ Pic_DeleteProfile() ; Deletes a picture profile - remove it from all associated items
;~ Pic_ReadProfileElem() ;Reads an element from a picture profile
;~ Pic_WriteProfileElem ;Writes to an element from a picture profile

;~ Img_PageForward() ;Updates the Gui array with next set of imgs in index
;~ Img_PageBack() ;Updates the gui array with last set of imgs in index
;~ Img_SetPageIndex() ;Loads a the index list of INIDs to Controls
;~ Img_AddPageIndex(ImgID) ;Adds a file to the current index

;~ Img_LoadVectors() ;Loads vectors from ImgUNID
;~ Img_ClearVectors() ;Clears current vectors

;~ Img_Set(ImgFullPath,CtrlHwnd,Large/Sm) ;Fills CtrlHwnd from ImgFullpath, select small or large
;~ Img_ConvertToJpeg(OutPutPath,InputPath,QualityOption) ;converts an img to jpeg for the lib
;~ Img_CreateMini(ImgFullPath,SaveFullPath) ;Creates a smaller, low res version of an img for lib
;~ Img_Scale(ImgFullPath,CtrlHwnd,Options) ;Scales an img to fit a control keeping it ratio


;~ Vector_CreateIndex() ;Creates an array for storing all VectUNID
;~ Vector_AddIndex() ;Adds a VectUNID to the vector space index
;~ Vector_SetIndex() ;Pass a list of VectUNIDs to define the vectorspace.


;~ Vector_Detect() ;Detects if mouse is over vector space, returns VectUNID undermouse
;~ Vector_DetectCollision() ;detects if a space is already part of another vecor, asking VectorIndex

;~ Vector_SelectionGet() ;using the color undermouse, gets an area for selection
;~ Vector_SelectionExpand() ;using the color undermouse, adds an area to the current select
;~ Vector_SelectionClear() ;Clears the currently selected area.


;~ Vector_Draw() ;Draws a line around a vector space using VectUNID
;~ Vector_DrawAll() ;Draws all vectors for an ImgUNID


;~ Vector_CreateProfile()
;~ Vector_DeleteProfile()
;~ Vector_ReadProfileElem()
;~ Vector_WriteProfileElem()

;~ Pic_ToggleVectorToolbar ;Shows/Hides Vector Toolbar

RandomUniqNum(List)
{
   Global
   Loop
   {
      Random R, 1, 2147483647                 ; R = random number
      If %List%_UniqIDList%R% = 1
         Continue     ; repetition found, try again   
      %List%_UniqIDList%R% = 1                      ; note occurrence
      break                                     ; different number
    }
   Return, R
}

SetUnigNumArray(List)
{
   Global
   Loop, Parse, List, `,
   {
      CompImgIDList_UniqIDList%A_LoopField% = 1
   }
}




;Remove these when merging with main script
ListAdd(Cont,List)
{
   If List =
      List := Cont
   Else
      List := Cont "," List
   Sort, List, D, N
   Return, List
}

;************************************************************************************************
ListRemove(Cont,ListIn)
{
   List =
   Loop, Parse, ListIn, `,
   {
      If A_LoopField = %Cont%
         Continue
      If List =
         List = %A_LoopField%
      Else
         List := A_LoopField "," List
   }
   Sort, List, D, N
   Return, List
}

F9::Reload
F10::ListLines

GuiClose:
Exit:
   Gdip_Shutdown( GDIPToken ) 
ExitApp


_________________
my lame sig :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2011, 3:45 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
I adjusted your script slightly to not be so wide. Please accept my apologies if I broke anything :!:

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, chaosad, Google Feedfetcher, MSN [Bot], Yahoo [Bot] and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group