-
2
- #1
Olaf Doschke
Programmer
I had a case of lost BMP images from a project folder, but got an APP file including the images. This code detects BMP files by it's simply header "BM" followed by size of the file in 2 bytes.
Maybe it'll help some other poor soul with the same problem. If you know the inner file structure of GIF, JPG, PNG, etc. you'd be able to find and extract them, too. In my case BMP was just fine.
Bye, Olaf.
Code:
#Define ccVFPApp "C:\...\your.exe"
#Define ccImageFolder "C:\extractedBMPs\"
Local lcVFPApp, lnBMPPosition, lcBMPHeader, i
i=1
Do While .T.
lnBMPPosition = At("BM",lcVFPApp,i)
If lnBMPPosition=0
Exit
Endif
lcBMPHeader = Substr(lcVFPApp,lnBMPPosition ,4)
lnSize = CToBin(Right(lcBMPHeader,2),"2RS")
If lnSize<=4
* wrong size, surely not a bmp
Else
lcFilename = "image"+PADL(i,3,"0")+".bmp"
StrToFile(Substr(lcVFPApp,lnBMPPosition ,lnSize),Addbs(ccImageFolder)+lcFilename)
Endif
i = i + 1
EndDo
Maybe it'll help some other poor soul with the same problem. If you know the inner file structure of GIF, JPG, PNG, etc. you'd be able to find and extract them, too. In my case BMP was just fine.
Bye, Olaf.