Results 1 to 3 of 3

Thread: Trouble using a type def from tifflib library

  1. #1
    Join Date
    Dec 2010
    Posts
    14
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Trouble using a type def from tifflib library

    I am using tifflib library in my QT code. I have linked the library into my project file and am able to call up methods from the library. However, the tifflib library defines a typedef void* tdata_t
    to promote portability. When I read a line from the tiff file it creates a buffer of tdata_t data. This corresponds to the actual pixel data that I want to retrieve from the image. The problem I am having is that I have been unable to cast this data as uint16 (the picture is a 16bit image).
    Right now I am trying to hardcode a specific image file to get it to work

    Qt Code:
    1. void Form1::loadImageFiles()
    2. {
    3. TIFF * tif = TIFFOpen("myimagefile", "r");
    4.  
    5. if(tif)
    6. {
    7. uint32 imagelength;
    8. tdata_t buf;
    9. uint32 row;
    10.  
    11. TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
    12. buf = _TIFFmalloc(TIFFScanlineSize(tif));
    13. row = 0;
    14. TIFFReadScanline(tif, buf, row);
    15. }
    To copy to clipboard, switch view to plain text mode 

    now here is where I have tried a couple of approaches.

    1)I have tried casting as a QVariant and then converting to a Uint

    2) created a pointer to the address of the buffer and then tried to casting to Uint, then I created a QVariant of the address and tried casting to uint16

    3)Tried to create a QPTRList <tdata_t> that contained uint16

    without success. I wanted to ask how you guys would handle this?

    Thank you for your help,

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Trouble using a type def from tifflib library

    Does this work?:
    Qt Code:
    1. unsigned short *pBuff = (unsigned short*)buf;
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    jstippey (18th January 2011)

  4. #3
    Join Date
    Dec 2010
    Posts
    14
    Thanks
    3
    Thanked 4 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Trouble using a type def from tifflib library

    Thank you, I believe that works.

Similar Threads

  1. Replies: 7
    Last Post: 19th April 2011, 12:20
  2. Replies: 2
    Last Post: 22nd December 2009, 20:52
  3. Replies: 4
    Last Post: 18th December 2009, 18:55
  4. Trouble linking static library
    By russdot in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2009, 10:56
  5. Type and User Type
    By campana in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2006, 23:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.