From: John Martens on
Saulo,

One could convert the JPG into BMP at startup of your app and the use it
as a resource ?

John


Saulo Rodrigues schreef:
> John, thanks for share your code, but that is not what I am looking
> for.
> Please let me try to explain it better:
>
> My real intention is do declare a resource entity:
> For example:
> RESOURCE MYJPG jpg c:\images\myjpg.jpg
>
> And so, like FabPaintLib:CreateFromResourceName(...) does:
> something like:
> CreateFromResourceName( _GetInst(), "MYJPG" )
> but this method only work for BMP's resources.
>
> Thanks again and sorry about your time
> Saulo
>
> John Martens escreveu:
>
>> Saulo,
>>
>> Here's my function to save a picture file in another format.
>>
>> John
>>
>>
>> FUNCTION PictureSaveAs(cFileNmOld AS STRING,cMode AS STRING) AS LOGIC
>> *
>> * function to save a file as DIB
>> * base from the code of FabPaint
>> * needs FabPaint Wrappers to use FabPaint.DLL instead of CaPaint.dll
>> LOCAL lFuncResult := FALSE AS LOGIC
>> LOCAL hf AS PTR
>> LOCAL dwSize AS DWORD
>> LOCAL pBmpBuffer AS PTR
>> LOCAL pDib AS PTR
>> LOCAL aKeuzeOpties := {} AS ARRAY
>> LOCAL dwKeuze AS DWORD
>> LOCAL cFileNmNew AS STRING
>> *
>> * see for the extension of the file
>> DO CASE
>> CASE ! File(cFileNmOld)
>> *
>> * file does not extist
>> ToonMelding('W','Bestand '+cFileNmOld+' bestaat niet.<.><.>Bestand kan
>> niet worden opgeslagen.',AlgShellWindow())
>> CASE Upper(LeesAlleenFileExt(cFileNmOld)) $
>> '|JPG|JPEG|TIF|TIFF|BMP|TGA|PNG|PCX|PCT|GIF|'
>> *
>> * get the pointer to the DIB
>> hf := FOpen(cFileNmOld)
>> IF hf = F_ERROR
>> *
>> * fileopen went wrong
>> ToonMelding('SU','Bestand '+cFileNmOld+' is niet te openen door
>> FOpen().<.><.>Bestand kan niet worden opgeslagen.',AlgShellWindow())
>> ELSE
>> dwSize := FSeek(hf, 0, FS_END)
>> FSeek(hf, 0, FS_SET)
>> pBmpBuffer := MemAlloc(dwSize)
>> DO CASE
>> CASE pBmpBuffer = NULL_PTR
>> *
>> * ptr not right
>> ToonMelding('SU','Bestand '+cFileNmOld+' geeft geen juiste
>> pointer.<.><.>Bestand kan niet worden opgeslagen.',AlgShellWindow())
>> CASE ! FRead3(hf, pBmpBuffer, dwSize) == dwSize
>> *
>> * filesize not right
>> ToonMelding('SU','Bestand '+cFileNmOld+' heeft niet de juiste
>> afmeting.<.><.>Afmeting kan niet worden opgehaald.',AlgShellWindow())
>> OTHERWISE
>> pDib := DIBCreateFromPTR(pBmpBuffer, dwSize)
>> IF Empty(pDib)
>> *
>> * DIB creation was wrong
>> ToonMelding('SU','Bestand '+cFileNmOld+' is niet te lezen door
>> DIBCreateFromPTR().<.><.>Bestand kan niet worden
>> opgeslagen.',AlgShellWindow())
>> ELSE
>> *
>> * kijken of soort op is gegeven
>> IF 'Format(' $ cMode
>>
>> AAdd(aKeuzeOpties,{'',LeesLinksVan(LeesRechtsVan(cMode,'Format('),')')})
>> dwKeuze := 1
>> ELSE
>> AAdd(aKeuzeOpties,{'JPEG formaat','JPG'})
>> AAdd(aKeuzeOpties,{'PNG formaat','PNG'})
>> AAdd(aKeuzeOpties,{'TIFF formaat','TIFF'})
>> AAdd(aKeuzeOpties,{'DIB formaat','DIB'})
>> dwKeuze := LeesKeuze('Kies formaat','Kies het formaat waarin
>> '+cFileNmOld+' moet worden opgeslagen.',aKeuzeOpties,'',AlgShellWindow())
>> ENDIF
>> *
>> * nieuwe naam als basis opbouwen
>> cFileNmNew := cFileNmOld
>> DO WHILE '.' $ cFileNmNew .and. (! Right(cFileNmNew,1) == '.')
>> cFileNmNew := LeesLinksVan(cFileNmNew,1)
>> ENDDO
>> *
>> * save as
>> DO CASE
>> CASE 'JPG' == aKeuzeOpties[dwKeuze,2]
>> cFileNmNew += 'JPG'
>> FileDel(cFileNmNew)
>> DIBSaveAsJPEG(pDib,String2Psz(cFileNmNew))
>> CASE 'PNG' == aKeuzeOpties[dwKeuze,2]
>> cFileNmNew += 'PNG'
>> FileDel(cFileNmNew)
>> DIBSaveAsPNG(pDib,String2Psz(cFileNmNew))
>> CASE 'TIFF' == aKeuzeOpties[dwKeuze,2]
>> cFileNmNew += 'TIFF'
>> FileDel(cFileNmNew)
>> DIBSaveAsTIFF(pDib,String2Psz(cFileNmNew))
>> OTHERWISE
>> cFileNmNew += 'DIB'
>> FileDel(cFileNmNew)
>> DIBSaveAs(pDib,String2Psz(cFileNmNew))
>> ENDCASE
>> IF File(cFileNmNew)
>> lFuncResult := TRUE
>> ELSE
>> *
>> * fileinfo was not right
>> ToonMelding('W','Bestand '+cFileNmOld+' is niet op te slaan als
>> '+cFileNmNew+'.<.><.>Bestand kan niet worden opgeslagen.',AlgShellWindow())
>> ENDIF
>> *
>> * delete the pointer
>> DIBDelete(pDib)
>> ENDIF
>> ENDCASE
>> FClose(hf)
>> MemFree(pBmpBuffer)
>> *
>> * kijken naar openen
>> IF lFuncResult .and. 'OPEN' $ cMode
>> Wacht(1,TRUE)
>> FileOpen(cFileNmNew,'',{})
>> ENDIF
>> ENDIF
>> OTHERWISE
>> *
>> * unforseen
>> ToonMelding('W','De extensie van bestand '+cFileNmOld+' is niet
>> voorzien.<.><.>Bestand kan niet worden opgeslagen.',AlgShellWindow())
>> ENDCASE
>> RETURN lFuncResult
>>
>>
>> Saulo Rodrigues schreef:
>>> Thanks Phil
>>>
>>>> DIBSaveAsJPEG(ptrBitmap, String2Psz(cFName))
>>> In fact I need the inverse one, something like: JPEGSaveAsBMP(ptrJPEG,
>>> String2Psz(cFName)). Anyway I think I will need an external DLL to do
>>> that.
>>>
>>> Regards
>>> Saulo
>>>
>
From: Saulo Rodrigues on
John,

> One could convert the JPG into BMP at startup of your app and the use it
> as a resource ?

I have an jpg file, which is knowingly smaller than an bitmap file, so
I think a file so small is better to have as a resource than a bitmap
file. On an VO context I need to handle that image and afaik that image
should be in a bitmap format. Another option would be to leave the
image as bitmap and put it in an VO dll, but at some tests that call
was relatively slow.

Thanks again
Saulo

From: GSchaller on
Saulo.

Unfortunately this is always a limitation you are going to have with VO.
Such is the problem when a product is frozen in its architecture the way
VO has been for so long. If you don't want to read the jpg from disk for
the app then you are really stuck with converting it to a resource and
placing it in the app. Even though the bmp format is larger, it should
be fast to use because it is already in memory after the app is loaded.

Geoff


"Saulo Rodrigues" <rj.saulo(a)gmail.com> wrote in message
news:1164140267.395885.126850(a)f16g2000cwb.googlegroups.com:

> John,
>
>
> > One could convert the JPG into BMP at startup of your app and the use it
> > as a resource ?
>
>
> I have an jpg file, which is knowingly smaller than an bitmap file, so
> I think a file so small is better to have as a resource than a bitmap
> file. On an VO context I need to handle that image and afaik that image
> should be in a bitmap format. Another option would be to leave the
> image as bitmap and put it in an VO dll, but at some tests that call
> was relatively slow.
>
> Thanks again
> Saulo

From: Dirk (Belgium) on
Hi,

If you have the jpeg in memory, you can do the following.

Create a device = hDC
Paint the jpeg to this hDC
Read the hDC as a bitmap (see VO-SDk window{}:Print()-method)
Save the bitmap (see Microsoft SDK)

Dirk

On 20 Nov 2006 03:46:57 -0800, "Saulo Rodrigues" <rj.saulo(a)gmail.com>
wrote:

>Hi everybody,
>
>With FabPaint I can create a jpeg file through a resource bitmap,
>however I'd like to make the inverse thing. Any help is welcome.
>
>TIA,
>Saulo

From: Saulo Rodrigues on
Geoff

Actually that bmp file is so big and then my app was very fat.

Thanks
Saulo

GSchaller escreveu:

> Saulo.
>
> Unfortunately this is always a limitation you are going to have with VO.
> Such is the problem when a product is frozen in its architecture the way
> VO has been for so long. If you don't want to read the jpg from disk for
> the app then you are really stuck with converting it to a resource and
> placing it in the app. Even though the bmp format is larger, it should
> be fast to use because it is already in memory after the app is loaded.
>
> Geoff
>
>
> "Saulo Rodrigues" <rj.saulo(a)gmail.com> wrote in message
> news:1164140267.395885.126850(a)f16g2000cwb.googlegroups.com:
>
> > John,
> >
> >
> > > One could convert the JPG into BMP at startup of your app and the use it
> > > as a resource ?
> >
> >
> > I have an jpg file, which is knowingly smaller than an bitmap file, so
> > I think a file so small is better to have as a resource than a bitmap
> > file. On an VO context I need to handle that image and afaik that image
> > should be in a bitmap format. Another option would be to leave the
> > image as bitmap and put it in an VO dll, but at some tests that call
> > was relatively slow.
> >
> > Thanks again
> > Saulo

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: CRC32
Next: CAVORT20.DLL and 2.7