Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Icon Stored In General Field - copy to .ico file how?
Message
De
12/06/2003 18:10:10
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Titre:
Icon Stored In General Field - copy to .ico file how?
Divers
Thread ID:
00799601
Message ID:
00799601
Vues:
64
I've been testing a few code examples I found on the UT for copying bmp files from a general field to an actual file, however, while they seem to work with .bmp files, I cannot get it to work with an icon file. It creates a file, but windows does not recognize it as an icon file and the file opens up empty or blank in windows image editor, picture editor, paint, etc. I have a table named 'bridges' with a general field named 'icon' which stores an actual icon file, not a link. My goal is to copy the icon file stored in the general field to a specific path and filename.

Here are the examples I've tried:
*Example 1
*Table is bridges.dbf
*general field is bridges.icon
*it is the actual icon file in the general field, not a link
*For testing purposes, I opened the table 
*and position the record pointer to a record with an icon in 
*the icon field
*I passed "icon" as the field name to this program.
*****************************************************************************
LPARAMETERS tcGenFldName

LOCAL lnInHandle
LOCAL lnOutHandle
LOCAL lnFileLen

LOCAL lcTmpFile
LOCAL lcBmpFile
LOCAL lcString

LOCAL loResult
LOCAL lcOldComp

lcTmpFile = ADDBS(SYS(2023)) + SYS(2015)
lcBmpFile = "c:\accuwin\sc\vendor\proaccu.ico"

COPY TO (lcTmpFile) FIELDS (tcGenFldName) NEXT 1

lnInHandle = FOPEN(lcTmpFile + '.FPT')
lnOutHandle = FCREATE(lcBmpFile)

IF lnInHandle >0 AND lnOutHandle > 0

    lnFileLen = FSEEK(lnInHandle, 0, 2)
    = FSEEK(lnInHandle, 0)

    lcString = FREAD(lnInHandle, lnFileLen)
    lcString = RIGHT(lcString, LEN(lcString) - 599)
    =FWRITE(lnOutHandle, lcString)
ELSE
    lcBmpFile = ''
ENDIF

=FCLOSE(lnInHandle)
=FCLOSE(lnOutHandle)

IF FILE(lcTmpFile + '.FPT')
    DELETE FILE (lcTmpFile + '.*')
ENDIF

RETURN lcBmpFile
**************************************************************************
USE bridges
GO top
COPY TO temp FIELDS icon NEXT 1
						
      *** and Create a file handle for the output file "Test.Bmp"
      handlein=FOPEN("temp.fpt")
      handleout=FCREATE("c:\accuwin\sc\vendor\proaccu.ico")

      *** To determine the length of the Input file "Temp.fpt"
      gnEnd = FSEEK(handlein, 0, 2)
      gnTop = FSEEK(handlein, 0)

      *** Store the whole file into a string "str1"
      str1 = FREAD(handlein, gnEnd)

      ***  Offset 599 bytes from Str1 and save it to "str2"
      str2=RIGHT(str1,LEN(str1)-599)

      *** Write "Str2" into the BMP file "Test.BMP"
      n=FWRITE(handleout,str2)

      *** Close both opened files
      =FCLOSE(handlein)
      =FCLOSE(handleout)
FLUSH
USE bridges
GO top
lctemp=sys(2015)
COPY GENERAL to (lctemp) next 1
lcOUtFileName="c:\accuwin\sc\vendor\proaccu.ico"
Hin = fopen(lcTemp+".fpt")
hout=fcreate(lcOutFileName)
lnSize=fseek(hin,0,2)
fseek(hin,0x204,0) && Move file pointer to offset 0x204 where file size is stored
lnSize = 0
for ix=4 to 1 step -1 && Get file size
  lnSize=lnSize+asc(fread(hin,1))*256^(ix-1)
endfor
fwrite(hout,fread(hin,lnSize),lnSize)
=fclose(hin) and fclose(hout)
flush
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform