Alaska Software Inc. - XbpBitmap
Username: Password:
AuthorTopic: XbpBitmap
Jose Antonio Diego KerejeXbpBitmap
on Sun, 08 Feb 2015 19:51:52 +0100
The XbpBitmap class seems to have a different behavior in v2.00 with 32 bpp
images.

Regards. Diego


---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
http://www.avast.com


Test.zip
Test.png
Till WarwegRe: XbpBitmap
on Wed, 18 Feb 2015 17:56:29 +0100
Dear Diego,

  Sorry for getting back to you so late.

May I ask how the image file was created? I can see that it has
32 bits color depth and that per-pixel transparency information
is also present in the file. Apparently, this is why the system
draws the image translucent up to the point where it becomes
invisible.

I can see that plainly, having transparent pixels wasn't intended.
That's why I'm asking how this format was created/saved.

Regards,
  Till Warweg
  [Alaska Software]

--------------------------------------------------------------------
Technical Support:         support@alaska-software.com
News Server:                 news.alaska-software.com
Homepage:                     http://www.alaska-software.com
KnowledgeBase:            http://www.alaska-software.com/kb
--------------------------------------------------------------------



"Jose Antonio Diego Kereje" schrieb im Newsbeitrag news:391eab26$5af99ce9$2a025@news.alaska-software.com...
> The XbpBitmap class seems to have a different behavior in v2.00 with 32 bpp
> images.
>
> Regards. Diego
>
>
> ---
> El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
> http://www.avast.com
>
Jose Antonio Diego KerejeRe: XbpBitmap
on Wed, 18 Feb 2015 23:21:07 +0100
Dear Till,

>  Sorry for getting back to you so late.

No problem, thanks for reply.

> May I ask how the image file was created? I can see that it has
> 32 bits color depth and that per-pixel transparency information
> is also present in the file. Apparently, this is why the system
> draws the image translucent up to the point where it becomes
> invisible.
>
> I can see that plainly, having transparent pixels wasn't intended.
> That's why I'm asking how this format was created/saved.
>

This is the code I use:

**************************************
STATIC FUNCTION CreateGrayBMP( cFile )
**************************************
LOCAL lSuccess:= .T.
LOCAL oImg    := CreateObject( 'WIA.ImageFile'    )
LOCAL oIP     := CreateObject( 'WIA.ImageProcess' )
LOCAL bError, oV, nCont, nLen, nColor, nGray, oPT, oPT2

bError := ErrorBlock( {|e| Break( e ) } )
BEGIN SEQUENCE
   oImg:loadFile( cFile + '.bmp' )

   oV  := oImg:ARGBData
   nLen:= oV:count

   FOR nCont:= 1 TO nLen
      nColor:= oV:getProperty( 'item', nCont )
      nGray := Int( ( BAnd( nColor, 255 ) + BAnd( nColor, 65280 ) / 256 +
BAnd( nColor, 16711680 ) / 65536 ) / 3 )
      nGray := Max( 90, Min( 255, Int( nGray * 1.4 ) ) )
      oV:setProperty( 'item', nCont, nGray + nGray * 256 + nGray * 65536 +
16777216 )
   NEXT
   oPT:= oIP:FilterInfos( "ARGB" )
      nCont:= oPT:FilterID
      oPT:destroy()

   oPT:= oIP:Filters
      oPT:Add( nCont )
      oPT:destroy()

   oPT:= oIP:Filters( 1 )
      oPT2:= oPT:Properties("ARGBData")
      oPT2:value := oV
      oPT2:destroy()
      oPT:destroy()

   cFile+= 'gray.bmp'

   FErase( cFile )

 oPT:= oIP:apply( oImg )
  oPT:saveFile( cFile )

   oV:destroy()
   oPT:destroy()
   oIP:destroy()
   oImg:destroy()
RECOVER
   lSuccess:= .F.
ENDSEQUENCE
ErrorBlock( bError )
RETURN lSuccess

In the previous version there was no problem to show these images in a
window. In v2.00 seems not possible.

Regards. Diego


---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
http://www.avast.com
Jose Antonio Diego KerejeRe: XbpBitmap
on Sun, 22 Feb 2015 22:33:48 +0100
Dear Till,

I changed the way to encode the gray and now works correctly in both
versions.

Regards. Diego


**************************************
STATIC FUNCTION CreateGrayBMP( cFile )
**************************************
LOCAL lSuccess:= .T.
LOCAL oImg    := CreateObject( 'WIA.ImageFile'    )
LOCAL oIP     := CreateObject( 'WIA.ImageProcess' )
LOCAL bError, oV, nCont, nLen, cColor, nGray, oPT, oPT2

bError := ErrorBlock( {|e| Break( e ) } )
BEGIN SEQUENCE
   oImg:loadFile( cFile + '.bmp' )

   oV  := oImg:ARGBData
   nLen:= oV:count

   FOR nCont:= 1 TO nLen
      cColor:= cDw2Hex( oV:getProperty( 'item', nCont ) )
      nGray := Int( 0.2126 * nHex2byte( cColor[ 3 ] + cColor[ 4 ] ) + 0.7152
* nHex2byte( cColor[ 5 ] + cColor[ 6 ] ) + ;
                    0.0722 * nHex2byte( cColor[ 7 ] + cColor[ 8 ] ) )
      nGray := Max( 90, Min( 255, Int( 1.4 * nGray ) ) )
      oV:setProperty( 'item', nCont, nHex2Dw( 'FF' + Replicate( cByte2Hex(
nGray ), 3 ) ) )
   NEXT
   oPT:= oIP:FilterInfos( "ARGB" )
      nCont:= oPT:FilterID
      oPT:destroy()

   oPT:= oIP:Filters
      oPT:Add( nCont )
      oPT:destroy()

   oPT:= oIP:Filters( 1 )
      oPT2:= oPT:Properties("ARGBData")
      oPT2:value := oV
      oPT2:destroy()
      oPT:destroy()

   oPT:= oIP:apply( oImg )

   cFile+= 'gray.bmp'
   FErase( cFile )
   oPT:saveFile( cFile )

   oV:destroy()
   oPT:destroy()
   oIP:destroy()
   oImg:destroy()
RECOVER
   lSuccess:= .F.
ENDSEQUENCE
ErrorBlock( bError )
RETURN lSuccess


---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
http://www.avast.com


Modesta1.png
Till WarwegRe: XbpBitmap
on Mon, 23 Feb 2015 15:52:00 +0100
Diego,

  Thanks for the update.

Apparently, what you did is to change the value of the
byte set aside for the alpha channel of each pixel. This
is why the image no longer appears translucent.

Well done .

Kind regards,
  Till Warweg
  [Alaska Software]

--------------------------------------------------------------------
Technical Support:         support@alaska-software.com
News Server:                 news.alaska-software.com
Homepage:                     http://www.alaska-software.com
KnowledgeBase:            http://www.alaska-software.com/kb
--------------------------------------------------------------------



"Jose Antonio Diego Kereje" schrieb im Newsbeitrag news:438fc411$5eff4051$1dadd0@news.alaska-software.com...
> Dear Till,
>
> I changed the way to encode the gray and now works correctly in both
> versions.
>
> Regards. Diego
>
>
> **************************************
> STATIC FUNCTION CreateGrayBMP( cFile )
> **************************************
> LOCAL lSuccess:= .T.
> LOCAL oImg    := CreateObject( 'WIA.ImageFile'    )
> LOCAL oIP     := CreateObject( 'WIA.ImageProcess' )
> LOCAL bError, oV, nCont, nLen, cColor, nGray, oPT, oPT2
>
> bError := ErrorBlock( {|e| Break( e ) } )
> BEGIN SEQUENCE
>   oImg:loadFile( cFile + '.bmp' )
>
>   oV  := oImg:ARGBData
>   nLen:= oV:count
>
>   FOR nCont:= 1 TO nLen
>      cColor:= cDw2Hex( oV:getProperty( 'item', nCont ) )
>      nGray := Int( 0.2126 * nHex2byte( cColor[ 3 ] + cColor[ 4 ] ) + 0.7152
> * nHex2byte( cColor[ 5 ] + cColor[ 6 ] ) + ;
>                    0.0722 * nHex2byte( cColor[ 7 ] + cColor[ 8 ] ) )
>      nGray := Max( 90, Min( 255, Int( 1.4 * nGray ) ) )
>      oV:setProperty( 'item', nCont, nHex2Dw( 'FF' + Replicate( cByte2Hex(
> nGray ), 3 ) ) )
>   NEXT
>   oPT:= oIP:FilterInfos( "ARGB" )
>      nCont:= oPT:FilterID
>      oPT:destroy()
>
>   oPT:= oIP:Filters
>      oPT:Add( nCont )
>      oPT:destroy()
>
>   oPT:= oIP:Filters( 1 )
>      oPT2:= oPT:Properties("ARGBData")
>      oPT2:value := oV
>      oPT2:destroy()
>      oPT:destroy()
>
>   oPT:= oIP:apply( oImg )
>
>   cFile+= 'gray.bmp'
>   FErase( cFile )
>   oPT:saveFile( cFile )
>
>   oV:destroy()
>   oPT:destroy()
>   oIP:destroy()
>   oImg:destroy()
> RECOVER
>   lSuccess:= .F.
> ENDSEQUENCE
> ErrorBlock( bError )
> RETURN lSuccess
>
>
> ---
> El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
> http://www.avast.com
>