loading members at runtime 2004-02-29 - By James Newton
Back On 28/2/04 4:02 pm, "noisecrime" <noise@(protected)> wrote:
> there appears to be no way to determine if a bitmap member has an alpha! > Am I missing a function? > Haven't tested importfileinto to see if it automatcially sets the usealpha > property (which member.filename doesn't).
Hi NoiseCrime,
Setting member().fileName maintains the current value of useAlpha, even if the new bitmap has no alpha channel. To force the value of useAlpha to update, you can create a new empty bitmap before you set the fileName:
do "new(#bitmap, member(1))"&RETURN& "fileIO = xtra(""E&"FileIO""E&").new()"&RETURN& "member(1).fileName = fileIO.displayOpen()"&RETURN& "put member(1).useAlpha"
(Remove Return characters before testing).
However, member().importFileInto() does modify useAlpha to suit the imported file:
do "fileIO = xtra(""E&"FileIO""E&").new()"&RETURN& "member(1).importFileInto(fileIO.displayOpen())"&RETURN& "put member(1).useAlpha"
Setting the fileName is faster than importFileInto(). On my machine with a test image, the results were:
set fileName 56 ms importFileInto 81 ms
However, the need to recreate a #bitmap with fileName tips the balance distincly the other way:
create bitmap, then set fileName 381 ms
So it looks as if the fastest technique would be to assume that, if the fileName contains ".jpg", then there is no alpha channel. The safest, fast technique would be to use importFileInto().
Cheers,
James
PS: I'm only using do() in the above examples to simplify testing ... and under the mistaken assumption that Colin could not produce the same result with a single line of code, without using do().
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ Dir3d-l mailing list Dir3d-l@(protected) http://nuttybar.drama.uga.edu/mailman/listinfo/dir3d-l
|
|