Swift returns 'UInt32' is not convertible to 'CGImage'












0















I got this error message based on code below:



Error message



/Users/MNurdin/Documents/iOS/XXXXX/HAHA.swift:534:38: 'UInt32' is not convertible to 'CGImage'


My code



let context : CGContextRef = CGBitmapContextCreate(nil, CGImageGetWidth(image.CGImage), CGImageGetHeight(image.CGImage),
CGImageGetBitsPerComponent(image.CGImage),
CGImageGetBytesPerRow(image.CGImage),
CGImageGetColorSpace(image.CGImage),
CGImageGetBitmapInfo(UInt32(image.CGImage)).rawValue)!;

CGContextConcatCTM(context, transform);









share|improve this question





























    0















    I got this error message based on code below:



    Error message



    /Users/MNurdin/Documents/iOS/XXXXX/HAHA.swift:534:38: 'UInt32' is not convertible to 'CGImage'


    My code



    let context : CGContextRef = CGBitmapContextCreate(nil, CGImageGetWidth(image.CGImage), CGImageGetHeight(image.CGImage),
    CGImageGetBitsPerComponent(image.CGImage),
    CGImageGetBytesPerRow(image.CGImage),
    CGImageGetColorSpace(image.CGImage),
    CGImageGetBitmapInfo(UInt32(image.CGImage)).rawValue)!;

    CGContextConcatCTM(context, transform);









    share|improve this question



























      0












      0








      0








      I got this error message based on code below:



      Error message



      /Users/MNurdin/Documents/iOS/XXXXX/HAHA.swift:534:38: 'UInt32' is not convertible to 'CGImage'


      My code



      let context : CGContextRef = CGBitmapContextCreate(nil, CGImageGetWidth(image.CGImage), CGImageGetHeight(image.CGImage),
      CGImageGetBitsPerComponent(image.CGImage),
      CGImageGetBytesPerRow(image.CGImage),
      CGImageGetColorSpace(image.CGImage),
      CGImageGetBitmapInfo(UInt32(image.CGImage)).rawValue)!;

      CGContextConcatCTM(context, transform);









      share|improve this question
















      I got this error message based on code below:



      Error message



      /Users/MNurdin/Documents/iOS/XXXXX/HAHA.swift:534:38: 'UInt32' is not convertible to 'CGImage'


      My code



      let context : CGContextRef = CGBitmapContextCreate(nil, CGImageGetWidth(image.CGImage), CGImageGetHeight(image.CGImage),
      CGImageGetBitsPerComponent(image.CGImage),
      CGImageGetBytesPerRow(image.CGImage),
      CGImageGetColorSpace(image.CGImage),
      CGImageGetBitmapInfo(UInt32(image.CGImage)).rawValue)!;

      CGContextConcatCTM(context, transform);






      ios swift






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 at 23:15









      halfer

      14.5k758111




      14.5k758111










      asked Sep 10 '15 at 9:18









      Mohammad NurdinMohammad Nurdin

      12.5k3193245




      12.5k3193245
























          3 Answers
          3






          active

          oldest

          votes


















          2














          As the error states you are passing a UInt32 to a function which expects a CGImage.



          CGImageGetBitmapInfo expects a CGImage as it's argument and returns CGBitmapInfo



          You are probably looking for:



          UInt32(CGImageGetBitmapInfo(image.CGImage).rawValue)





          share|improve this answer
























          • please check my edited question.

            – Mohammad Nurdin
            Sep 10 '15 at 9:34











          • @Dato'MohammadNurdin: Still you are using the old way, did you changed that code as mentioned in my answer ?

            – Midhun MP
            Sep 10 '15 at 9:35











          • I got this error message, 'UInt32' is not convertible to 'CGBitmapInfo'

            – Mohammad Nurdin
            Sep 10 '15 at 9:46











          • @Dato'MohammadNurdin Remove that UInt32 conversion from above code

            – Midhun MP
            Sep 10 '15 at 9:51













          • I got 'UInt32' is not convertible to 'CGImage'.

            – Mohammad Nurdin
            Sep 10 '15 at 10:00



















          1














          It's exactly as the error states, you can't convert a number to a CGImage



          I'm not sure why you're trying to convert a CGImage into a UInt32 before passing it into CGImageGetBitmapInfo. Just pass the CGImage in directly.



          CGImageGetBitmapInfo(image.CGImage);





          share|improve this answer



















          • 2





            I got 'UInt32' is not convertible to 'CGBitmapInfo'.

            – Mohammad Nurdin
            Sep 10 '15 at 9:26



















          1














          Raw value is returning UInt32 so try:



          CGImageGetBitmapInfo(image.CGImage).rawValue





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32497832%2fswift-returns-uint32-is-not-convertible-to-cgimage%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            As the error states you are passing a UInt32 to a function which expects a CGImage.



            CGImageGetBitmapInfo expects a CGImage as it's argument and returns CGBitmapInfo



            You are probably looking for:



            UInt32(CGImageGetBitmapInfo(image.CGImage).rawValue)





            share|improve this answer
























            • please check my edited question.

              – Mohammad Nurdin
              Sep 10 '15 at 9:34











            • @Dato'MohammadNurdin: Still you are using the old way, did you changed that code as mentioned in my answer ?

              – Midhun MP
              Sep 10 '15 at 9:35











            • I got this error message, 'UInt32' is not convertible to 'CGBitmapInfo'

              – Mohammad Nurdin
              Sep 10 '15 at 9:46











            • @Dato'MohammadNurdin Remove that UInt32 conversion from above code

              – Midhun MP
              Sep 10 '15 at 9:51













            • I got 'UInt32' is not convertible to 'CGImage'.

              – Mohammad Nurdin
              Sep 10 '15 at 10:00
















            2














            As the error states you are passing a UInt32 to a function which expects a CGImage.



            CGImageGetBitmapInfo expects a CGImage as it's argument and returns CGBitmapInfo



            You are probably looking for:



            UInt32(CGImageGetBitmapInfo(image.CGImage).rawValue)





            share|improve this answer
























            • please check my edited question.

              – Mohammad Nurdin
              Sep 10 '15 at 9:34











            • @Dato'MohammadNurdin: Still you are using the old way, did you changed that code as mentioned in my answer ?

              – Midhun MP
              Sep 10 '15 at 9:35











            • I got this error message, 'UInt32' is not convertible to 'CGBitmapInfo'

              – Mohammad Nurdin
              Sep 10 '15 at 9:46











            • @Dato'MohammadNurdin Remove that UInt32 conversion from above code

              – Midhun MP
              Sep 10 '15 at 9:51













            • I got 'UInt32' is not convertible to 'CGImage'.

              – Mohammad Nurdin
              Sep 10 '15 at 10:00














            2












            2








            2







            As the error states you are passing a UInt32 to a function which expects a CGImage.



            CGImageGetBitmapInfo expects a CGImage as it's argument and returns CGBitmapInfo



            You are probably looking for:



            UInt32(CGImageGetBitmapInfo(image.CGImage).rawValue)





            share|improve this answer













            As the error states you are passing a UInt32 to a function which expects a CGImage.



            CGImageGetBitmapInfo expects a CGImage as it's argument and returns CGBitmapInfo



            You are probably looking for:



            UInt32(CGImageGetBitmapInfo(image.CGImage).rawValue)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 10 '15 at 9:28









            Midhun MPMidhun MP

            62.9k24129175




            62.9k24129175













            • please check my edited question.

              – Mohammad Nurdin
              Sep 10 '15 at 9:34











            • @Dato'MohammadNurdin: Still you are using the old way, did you changed that code as mentioned in my answer ?

              – Midhun MP
              Sep 10 '15 at 9:35











            • I got this error message, 'UInt32' is not convertible to 'CGBitmapInfo'

              – Mohammad Nurdin
              Sep 10 '15 at 9:46











            • @Dato'MohammadNurdin Remove that UInt32 conversion from above code

              – Midhun MP
              Sep 10 '15 at 9:51













            • I got 'UInt32' is not convertible to 'CGImage'.

              – Mohammad Nurdin
              Sep 10 '15 at 10:00



















            • please check my edited question.

              – Mohammad Nurdin
              Sep 10 '15 at 9:34











            • @Dato'MohammadNurdin: Still you are using the old way, did you changed that code as mentioned in my answer ?

              – Midhun MP
              Sep 10 '15 at 9:35











            • I got this error message, 'UInt32' is not convertible to 'CGBitmapInfo'

              – Mohammad Nurdin
              Sep 10 '15 at 9:46











            • @Dato'MohammadNurdin Remove that UInt32 conversion from above code

              – Midhun MP
              Sep 10 '15 at 9:51













            • I got 'UInt32' is not convertible to 'CGImage'.

              – Mohammad Nurdin
              Sep 10 '15 at 10:00

















            please check my edited question.

            – Mohammad Nurdin
            Sep 10 '15 at 9:34





            please check my edited question.

            – Mohammad Nurdin
            Sep 10 '15 at 9:34













            @Dato'MohammadNurdin: Still you are using the old way, did you changed that code as mentioned in my answer ?

            – Midhun MP
            Sep 10 '15 at 9:35





            @Dato'MohammadNurdin: Still you are using the old way, did you changed that code as mentioned in my answer ?

            – Midhun MP
            Sep 10 '15 at 9:35













            I got this error message, 'UInt32' is not convertible to 'CGBitmapInfo'

            – Mohammad Nurdin
            Sep 10 '15 at 9:46





            I got this error message, 'UInt32' is not convertible to 'CGBitmapInfo'

            – Mohammad Nurdin
            Sep 10 '15 at 9:46













            @Dato'MohammadNurdin Remove that UInt32 conversion from above code

            – Midhun MP
            Sep 10 '15 at 9:51







            @Dato'MohammadNurdin Remove that UInt32 conversion from above code

            – Midhun MP
            Sep 10 '15 at 9:51















            I got 'UInt32' is not convertible to 'CGImage'.

            – Mohammad Nurdin
            Sep 10 '15 at 10:00





            I got 'UInt32' is not convertible to 'CGImage'.

            – Mohammad Nurdin
            Sep 10 '15 at 10:00













            1














            It's exactly as the error states, you can't convert a number to a CGImage



            I'm not sure why you're trying to convert a CGImage into a UInt32 before passing it into CGImageGetBitmapInfo. Just pass the CGImage in directly.



            CGImageGetBitmapInfo(image.CGImage);





            share|improve this answer



















            • 2





              I got 'UInt32' is not convertible to 'CGBitmapInfo'.

              – Mohammad Nurdin
              Sep 10 '15 at 9:26
















            1














            It's exactly as the error states, you can't convert a number to a CGImage



            I'm not sure why you're trying to convert a CGImage into a UInt32 before passing it into CGImageGetBitmapInfo. Just pass the CGImage in directly.



            CGImageGetBitmapInfo(image.CGImage);





            share|improve this answer



















            • 2





              I got 'UInt32' is not convertible to 'CGBitmapInfo'.

              – Mohammad Nurdin
              Sep 10 '15 at 9:26














            1












            1








            1







            It's exactly as the error states, you can't convert a number to a CGImage



            I'm not sure why you're trying to convert a CGImage into a UInt32 before passing it into CGImageGetBitmapInfo. Just pass the CGImage in directly.



            CGImageGetBitmapInfo(image.CGImage);





            share|improve this answer













            It's exactly as the error states, you can't convert a number to a CGImage



            I'm not sure why you're trying to convert a CGImage into a UInt32 before passing it into CGImageGetBitmapInfo. Just pass the CGImage in directly.



            CGImageGetBitmapInfo(image.CGImage);






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 10 '15 at 9:23









            Steve WilfordSteve Wilford

            7,03942760




            7,03942760








            • 2





              I got 'UInt32' is not convertible to 'CGBitmapInfo'.

              – Mohammad Nurdin
              Sep 10 '15 at 9:26














            • 2





              I got 'UInt32' is not convertible to 'CGBitmapInfo'.

              – Mohammad Nurdin
              Sep 10 '15 at 9:26








            2




            2





            I got 'UInt32' is not convertible to 'CGBitmapInfo'.

            – Mohammad Nurdin
            Sep 10 '15 at 9:26





            I got 'UInt32' is not convertible to 'CGBitmapInfo'.

            – Mohammad Nurdin
            Sep 10 '15 at 9:26











            1














            Raw value is returning UInt32 so try:



            CGImageGetBitmapInfo(image.CGImage).rawValue





            share|improve this answer




























              1














              Raw value is returning UInt32 so try:



              CGImageGetBitmapInfo(image.CGImage).rawValue





              share|improve this answer


























                1












                1








                1







                Raw value is returning UInt32 so try:



                CGImageGetBitmapInfo(image.CGImage).rawValue





                share|improve this answer













                Raw value is returning UInt32 so try:



                CGImageGetBitmapInfo(image.CGImage).rawValue






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Sep 21 '15 at 15:00









                gattshjotygattshjoty

                33937




                33937






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32497832%2fswift-returns-uint32-is-not-convertible-to-cgimage%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Callistus III

                    Plistias Cous

                    Index Sanctorum