Squirrel static lib

Mac OSX specific forum
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Squirrel static lib

Post by grabiller »

wilbert wrote:For the box with 'subscription' inside it, the problem indeed still exists.
The other controls are looking better now. I don't know if that one is drawn in another way.
It seems there is still something wrong in v5b4, but with the alpha channel.

It's like the alpha channel of the images is affected by the color space. This should not be, alpha channel must stay untouched and in linear space.

My controls are looking better but in fact if you look at the top and bottom side of the button, there are 'bold' lines which do not look this way on Windows and Linux.

It's like the alpha channel is 'stronger' on Mac, that's what makes me think the alpha channel is affected by the color space.
guy rabiller | radfac founder / ceo | raafal.org
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Squirrel static lib

Post by wilbert »

I agree the problem is not fixed yet and it is still a bug.

What you can do for now, as a temporary fix, is overwrite the DrawImage command with cocoa calls.
If you insert this code in the beginning of your application and have the lib with the CocoaMessage command installed, it will overwrite the DrawImage command.

Code: Select all

; *** DrawImage rewrite ***

Procedure DrawImgEx(ImageID, x, y, Width, Height)
  Protected srcRect.NSRect, dstRect.NSRect, delta.CGFloat = 1.0
  CocoaMessage(@srcRect\size, ImageID, "size")
  If Width < 0 Or Height < 0
    dstRect\size = srcRect\size
  Else
    dstRect\size\width = Width
    dstRect\size\height = Height
  EndIf
  dstRect\origin\x = x
  dstRect\origin\y = OutputHeight() - dstRect\size\height - y
  CocoaMessage(0, ImageID, "drawInRect:@", @dstRect, "fromRect:@", @srcRect, "operation:", #NSCompositeSourceOver, "fraction:@", @delta)  
EndProcedure

Macro DrawImage(ImageID, x, y, Width = -1, Height = -1)
  DrawImgEx(ImageID, x, y, Width, Height)
EndMacro

; *** End of DrawImage rewrite ***
It doesn't fix the bug, it's only a workaround.

Edit :
I updated the code because there was a bug in my code resulting in the wrong drawing coordinates.
I also want to point out that it doesn't respect the PureBasic drawing mode.
#NSCompositeSourceOver has the same effect as #PB_2DDrawing_AlphaBlend.
#NSCompositeCopy has the same effect as #PB_2DDrawing_AllChannels.
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Squirrel static lib

Post by grabiller »

Thanks wilbert.

Indeed that fixes the problem, as a workaround that is.

My images are now correctly drawn with proper alpha channel, including the 'Subscription' disabled button.

I hope it's straightforward to fix in PB for a beta 5.
guy rabiller | radfac founder / ceo | raafal.org
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

Re: Squirrel static lib

Post by grabiller »

Here is the result for you to check:
http://www.raafal.org/download/raafal.x ... macosx.zip

Here it works correctly now.
guy rabiller | radfac founder / ceo | raafal.org
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Squirrel static lib

Post by wilbert »

Yes, this one looks totally fine.
Hopefully Fred will find the solution to the stretched image drawing issue so you don't need a workaround.
Post Reply