Problem with save in TIFF format

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

Guest

Problem with save in TIFF format

Post by Guest »

Hello,

I would like to get an image from a window and convert it into TIF black&white format.

import HWND and change color depth are done (no message error)
but i don't manage to save bitmap into TIF file (error=GFL_ERROR_BAD_FORMAT_INDEX).

I tried other formats to test => same error.

what's wrong with my code ?

Code: Select all

                GFL_ERROR err;
                GFL_BITMAP *bitmap;

                GFL_RECT rct;
                rct.x=rectSel.left; // WINAPI RECT rectSel : global var
                rct.y=rectSel.top;
                rct.w=rectSel.right-rectSel.left;
                rct.h=rectSel.bottom-rectSel.top;

                err = gflImportFromHWND (hwnd, &rct, &bitmap);
                if (err) goto errato;
 
               GFL_BITMAP *bitmapOut;

               err = gflChangeColorDepth (bitmap, &bitmap,GFL_MODE_TO_BINARY, GFL_MODE_HALTONE90_DITHER);
                if (err) goto errato;

                GFL_SAVE_PARAMS sp;
                gflGetDefaultSaveParams(&sp);

                sp.Flags = GFL_SAVE_REPLACE_EXTENSION;
                sp.FormatIndex = gflGetFormatIndexByName("tiff");

                err = gflSaveBitmap("sortie.tif", bitmap, &sp);
                if (err) goto errato;

                return TRUE;

                errato:;
                 if (err) exit(err) ;
User avatar
xnview
Author of XnView
Posts: 43132
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Problem with save in TIFF format

Post by xnview »

Anonymous wrote:I would like to get an image from a window and convert it into TIF black&white format.
import HWND and change color depth are done (no message error)
but i don't manage to save bitmap into TIF file (error=GFL_ERROR_BAD_FORMAT_INDEX).
Strange, all seems to be good.

Code: Select all

               err = gflChangeColorDepth (bitmap, &bitmap,GFL_MODE_TO_BINARY, GFL_MODE_HALTONE90_DITHER);
Try to replace by:

Code: Select all

err = gflChangeColorDepth (bitmap, NULL,GFL_MODE_TO_BINARY, GFL_MODE_HALTONE90_DITHER);
Pierre.