Jump to content

Partial PNG Image data pre-scan.


Recommended Posts

Kinda wondering about potential speedups in relation to reading partial PNG image data.

The intended target here is to do a 'as short/fast as possible' initial partial-image data scan.

The thing here is that in the below function. GDIPlus will off course read and process the whole PNG image file. (with the PNG decoding part probably taking the biggest time slice.)

Running it on ~1050 small PNG files take about 5 and 6 seconds. (not that bad for a full scan, But pointless to use it for a partial image pre-scan.)

Where a crc scan on the whole image data takes ~6 second, And a partial crc scan, on the first image line, takes ~5 seconds. (the time difference between the two cases is probebly mainly because of the different amount of data that the crc function gets to process.

So I'm kinda wondering what would be potential solutions for a significant faster image data pre-scan with AutoIt.

If there is any real/practical solution that is. The only one that comes to my mind at the moment is that this probably is only achievable with some dedicated PNG related Assembly code. (which is not going to happen in my case.)

Any thoughts on the matter? ...

(Probably should stick to Python for this. But I like to try it in both Python and AutoIt.)

;; ref link: http://www.autoitscript.com/forum/topic/140478-bitmap-processing-using-raw-code/
Func _FUNCTION_DUMP_E3_($sFilespec) ;; looped function.
;~  _GDIPlus_Startup() ;; used before loop

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFilespec)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage)

    Local $tBitmap = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iWidth, $iHeight, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;; $GDIP_ILMREAD needed?
    Local $Stride = DllStructGetData($tBitmap, "Stride")
    Local $Scan0 = DllStructGetData($tBitmap, "Scan0")

    ;; test case lines.
    Local $v_Buffer = DllStructCreate("byte[" & $Stride  & "]", $Scan0) ;; ~1050 files, ~5sec
;~  Local $v_Buffer = DllStructCreate("byte[" & $Stride * $iHeight & "]", $Scan0) ;; ~1050 files, ~6sec

    Local $iCRC32 = _CRC32(DllStructGetData($v_Buffer,1))
    #forceref $iCRC32

    _GDIPlus_BitmapUnlockBits($hImage, $tBitmap)
    _GDIPlus_ImageDispose($hImage)

;~  _GDIPlus_Shutdown() ;; used after loop
EndFunc

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...