Loading image from DIB
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Loading image from DIB

Hybrid View

  1. #1
    Join Date
    Jul 2010
    Posts
    14

    Cool Loading image from DIB

    Hello, I am trying to take an image which has been loaded to the DIB and display it (right now I'm just trying to get it to display on the "main window" anyway possible, picturebox would be ideal but isn't necessary at the moment. Anyway here is my code:

    Code:
    int loadjpgfilefrombuffer(LPTSTR fname, imgdes *image)
    { ....
       HDC hDC;
       PAINTSTRUCT ps;
       HPALETTE hpal;
    
       hDC = BeginPaint(NULL, &ps);
       /* Display the image beginning at (0,0) */
       viewimageex(NULL, hDC, &hpal, 0, 0, &image,0,0,VIEWDITHER);      
       EndPaint(NULL, &ps);
    }
    The part of code I left out is a function that takes an image file (jpg) and allocates a DIB to load it into then loads it.

    I am getting the following error:

    error C2664: 'viewimageex' : cannot convert parameter 6 from 'imgdes **__w64 ' to 'imgdes *'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    If you have any thoughts or advice please share them. I can provide more information if needed just ask didn't want to post all the code as it wasn't relevant. Thank you.


    EDIT: I did a reinterpret cast to get it to imgdes* so now it runs fine with no errors but no image is displayed? Can anyone help?
    Last edited by syg19; July 13th, 2010 at 04:39 PM.

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Loading image from DIB

    'viewimageex' takes in a pointer to an 'imgdes' object, but your passing in a pointer to a pointer of an 'imgdes' object.

    Don't throw casts around just to get rid of compiler errors. Your function already has the proper pointer, remove the '&' from the 'image' parameter when you call 'viewimage'.

    Viggy

  3. #3
    Join Date
    Jul 2010
    Posts
    14

    Re: Loading image from DIB

    Thanks for the reply Viggy,

    I changed it to image and it compiled fine but still no image was displayed when I ran the program. Sorry about the pointer confusion still pretty new to programming and C++, can you offer any advice on why nothing is showing or any other ways to display an image thats in the DIB?

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Loading image from DIB

    Unfortunately, no. "viewimageex" is not an API function (search of the MSDN brought up nothing).

    Viggy

  5. #5
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    422

    Re: Loading image from DIB

    if you can put the code here. it would be helpful for the people to read it and solve your problem :-)

  6. #6
    Join Date
    Jul 2010
    Posts
    14

    Re: Loading image from DIB

    the code of what, the viewimageex function or the code I am using to implement it?

  7. #7
    Join Date
    Jul 2010
    Posts
    8

    Re: Loading image from DIB

    if you want to display a jpeg image
    you can use IPicture. or use CXImage, it is an open source project.

    you can put your function "viewimageex" code here. maybe someone can help you

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center