Bug 2379 - CGImage related iphone sdk samples don't work
Summary: CGImage related iphone sdk samples don't work
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-12-06 23:50 UTC by Art
Modified: 2011-12-09 18:47 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
CGImage sample (28.06 KB, application/zip)
2011-12-09 13:33 UTC, Art
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Art 2011-12-06 23:50:28 UTC
I couldn't get CGImage related iphone sdk samples to work. 
For example, the following code doesn't work.

UIImage myImage = UIImage.FromFile("myImage.png");
SetTransparent(myImage);



CGImage SetTransparent  (UIImage image)
               {
                       CGImage rawImageRef = image.CGImage
       CGImage rawImageRef = image.CGImage;
       float [] colorMasking =new float[6]     {222, 255, 222, 255, 222, 255}
;
       CGImage maskedImageRef = rawImageRef.WithMaskingColors(colorMasking);

return maskedImageRef
}
Comment 1 Rolf Bjarne Kvinge [MSFT] 2011-12-09 09:58:58 UTC
You're not doing anything with the image SetTransparent returns. Can you add a complete (compilable) test case we can try out?
Comment 2 Art 2011-12-09 13:33:26 UTC
Created attachment 1023 [details]
CGImage sample

I attached the CGImage project.

I am trying to convert the samples in the following URL
http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html
Comment 3 Rolf Bjarne Kvinge [MSFT] 2011-12-09 18:47:37 UTC
It seems to depend on the image. I converted img1.png to a jpg, and the masking works (you'll also have to change the coefficients to be in the range 0.0-1.0).

This is probably because the png already has an alpha channel.

Here are a few related links:
http://stackoverflow.com/questions/3563770/why-is-cgimagecreatewithmaskingcolors-returning-nil-in-this-case
http://lists.apple.com/archives/quartz-dev/2009/Mar/msg00015.html

I haven't tested it, but creating a context with the correct channels like this might make it possible to use your png:
http://stackoverflow.com/questions/633722/how-to-make-one-color-transparent-on-a-uiimage