DropIt

If you are currently developing portable freeware or planning to do so, use this forum to discuss technical implementation, seek out like-minded developers for partnership, or solicit interested users for beta testing.
Message
Author
User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1171 Post by Lupo73 »

I made a new test version with some error messages (let me know if you see something or not before the crash, thanks!):
http://www.lupopensuite.com/files/dropi ... table5.zip

The new system to store settings allowed to extent some features. You can find old versions here:
http://sourceforge.net/projects/dropit/files/DropIt/

User avatar
SYSTEM
Posts: 2043
Joined: Sat Jul 31, 2010 1:19 am
Location: Helsinki, Finland

Re: DropIt

#1172 Post by SYSTEM »

Lupo73 wrote: I made a new test version with some error messages (let me know if you see something or not before the crash, thanks!):
http://www.lupopensuite.com/files/dropi ... table5.zip
It doesn't give me any messages before crashing.
My YouTube channel | Release date of my 13th playlist: August 24, 2020

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1173 Post by Lupo73 »

The function that cause the crash is _GDIPlus_ImageGetGraphicsContext(). Now the problem is to determinate the reason of the crash in this main function (maybe guinness or other AutoIt coders have an idea about it):

Code: Select all

Func __SetItemImage($gImageFile, $gIndex, $gHandle = 0, $gType = 1, $gResource = 1, $gWidth = 20, $gHeight = 20)
	#cs
		Description: Set Image To GUI/Tray Context Menu.
		Returns: Converted Image.
	#ce
	If __IsWindowsVersion() = 0 Or __IsClassicTheme() Then
		Return SetError(1, 0, 0)
	EndIf
	Local $gImage
	Switch $gType
		Case 0 ; Native GUI ContextMenu.
			$gHandle = GUICtrlGetHandle($gHandle)
		Case 1 ; Native TrayMenu ContextMenu.
			$gHandle = TrayItemGetHandle($gHandle)
		Case 2
			$gHandle = $gHandle ; UDF Functions.
	EndSwitch
	Switch $gResource
		Case 1
			$gImage = _ResourceGetAsBitmap($gImageFile)
			_GUICtrlMenu_SetItemBmp($gHandle, $gIndex, $gImage)
			Return SetError(0, 0, $gImage)
		Case Else
			Local $gBitmap, $gContext, $gIcon, $gImageHeight, $gImageWidth
			$gImage = _GDIPlus_BitmapCreateFromFile($gImageFile)
			$gImageWidth = _GDIPlus_ImageGetWidth($gImage)
			$gImageHeight = _GDIPlus_ImageGetHeight($gImage)
			If $gImageWidth < 0 Or $gImageHeight < 0 Then
				Return SetError(1, 0, 0)
			EndIf
			If $gImageWidth < $gImageHeight Then
				$gImageWidth = $gWidth * $gImageWidth / $gImageHeight
				$gImageHeight = $gHeight
			Else
				$gImageHeight = $gHeight * $gImageHeight / $gImageWidth
				$gImageWidth = $gWidth
			EndIf
			$gBitmap = _GDIPlus_BitmapCreateFromScan0($gWidth, $gHeight)
			$gContext = _GDIPlus_ImageGetGraphicsContext($gBitmap) ; <<<<<<<<<<<<<<<<<<<<<<<
			_GDIPlus_GraphicsDrawImageRect($gContext, $gImage, 0, 0, $gWidth, $gHeight)
			$gIcon = _GDIPlus_BitmapCreateHBITMAPFromBitmap($gBitmap)
			_GUICtrlMenu_SetItemBmp($gHandle, $gIndex, $gIcon)
			_GDIPlus_GraphicsDispose($gContext)
			_GDIPlus_BitmapDispose($gBitmap)
			_GDIPlus_BitmapDispose($gImage)
			Return SetError(0, 0, $gIcon)
	EndSwitch
EndFunc   ;==>__SetItemImage

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: DropIt

#1174 Post by guinness »

Provide a reproducer i.e. something small and runnable.

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1175 Post by Lupo73 »

I'm trying to do it, even if this example (taken from the Help) works fine and so I'm a little confused of what could be the cause. :(

Code: Select all

#include <GDIPlus.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = 460, $iH = 100
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;create an empty bitmap
    Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the graphics context of the bitmap
    _GDIPlus_GraphicsSetSmoothingMode($hBmpCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hBmpCtxt, 0xFFFFFFFF) ;clear bitmap with color white
    _GDIPlus_GraphicsDrawString($hBmpCtxt, "DropIt Test", 0, 0, "Comic Sans MS", 52) ;draw some text to the bitmap
    Local $sFile = @TempDir & "\Test.jpg"
    _GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save bitmap to disk
    ;cleanup GDI+ resources
    _GDIPlus_GraphicsDispose($hBmpCtxt)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    ShellExecute($sFile) ;open bitmap with default app
EndFunc   ;==>Example
ps: do you think the __SetItemImage() function may be improved? Because for example I'm not sure if the following lines are needed.

Code: Select all

$gImageWidth = _GDIPlus_ImageGetWidth($gImage)
$gImageHeight = _GDIPlus_ImageGetHeight($gImage)
If $gImageWidth < 0 Or $gImageHeight < 0 Then
	Return SetError(1, 0, 0)
EndIf
If $gImageWidth < $gImageHeight Then
	$gImageWidth = $gWidth * $gImageWidth / $gImageHeight
	$gImageHeight = $gHeight
Else
	$gImageHeight = $gHeight * $gImageHeight / $gImageWidth
	$gImageWidth = $gWidth
EndIf

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: DropIt

#1176 Post by guinness »

Well will the graphic sizes be the same?

Also, the repository on SourceForge is outdated by a year. I was just thinking of having a look at the code and committing some potential fixes.

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1177 Post by Lupo73 »

I interrupted the SVN use given that I was the only developer (now I'm trying to restore it, even if I have some problems with TortoiseSVN). You can find the updated code here:
http://www.lupopensuite.com/files/dropi ... Source.zip

Thanks for your help with the code, this 64bit issue is incomprehensible for me! I have a 32bit system and so I'm asking tests to some users. The last bad news is that disabling __SetItemImage() function doesn't bypass the crash (or maybe it crashes somewhere else, I'm sending an updated test version to verify it).

About the lines I reported, the graphic sizes may be different. The fact is that $gImageWidth and $gImageHeight are not used in next lines, while probably they may replace $gWidth and $gHeight.

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: DropIt

#1178 Post by guinness »

When I left development everything was working on 64bit. I will see if I can find time to have a look outside of AutoIt development.

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1179 Post by Lupo73 »

Thanks, any fix or improvement is welcome. The problem started from version 5.3 and one of the changes is the use of the next AutoIt beta. As said, I'm not sure it is the cause of the issue, I'll try to compile a version with previous stable version to test it.

ps: I'm not able to restore the SVN system on my computer, maybe we could use dropbox to share updates together :roll:

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1180 Post by Lupo73 »

The problem was that _GDIPlus_BitmapCreateFromScan0() didn't support 64bit OS, this is a text version that may correctly works: http://www.lupopensuite.com/files/dropi ... table3.zip

I made few minor changes and updated also the source code. I'm considering to immediately release this fix and then go on with development.

User avatar
guinness
Posts: 4118
Joined: Mon Aug 27, 2007 2:00 am
Contact:

Re: DropIt

#1181 Post by guinness »

Lupo73 wrote:I'm not able to restore the SVN system on my computer, maybe we could use dropbox to share updates together :roll:
I don't have dropbox and when we worked like that in the past it was inefficient.

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1182 Post by Lupo73 »

What solution do you propose for best efficiency? I'll try to configure SVN, or something else is better?

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

Re: DropIt

#1183 Post by tproli »

Git?

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1184 Post by Lupo73 »

SVN repository fixed :D (the last tortoisesvn update didn't recognize my authentication settings, I needed to manually remove them from registry and fix repository configs to make it working).. it may simplify the collaboration!

I'm publishing current version 5.3.1 to immediately have a fixed version available, then the plan is to do some more improvements and release version 5.4 with updated translations too.

User avatar
Lupo73
Posts: 1012
Joined: Mon Mar 19, 2007 8:55 am
Location: Italy
Contact:

Re: DropIt

#1185 Post by Lupo73 »

Still problems. Now DropIt 64bit crashes during file processing (I'm considering to go back to the previous compiler version). If someone would like to help with tests, this is a version with "step messages" to help me to detect the crash position: http://www.lupopensuite.com/files/dropi ... table4.zip

Post Reply