gflSaveBitmapW() + gflJpegLosslessTransform() = crop

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

Moderators: XnTriq, helmut, xnview

User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm

gflSaveBitmapW() + gflJpegLosslessTransform() = crop

Post by AmigoJack »

Using gflSaveBitmapW() or gflJpegLosslessTransform() on its own works fine, as expected. However, if I use both in combination I miss 8 pixel rows from the original picture after lossless Jpeg transformation. To reconstruct, use the following code (Delphi):

Code: Select all

var
  vLoadParam: GFL_LOAD_PARAMS;
  vSaveParam: GFL_SAVE_PARAMS;
  pBmp: PGFL_BITMAP;
begin
  gflGetDefaultLoadParams( vLoadParam );

  gflGetDefaultSaveParams( vSaveParam );
  vSaveParam.FormatIndex:= gflGetFormatIndexByName( PChar( 'jpeg' ) );
  vSaveParam.OptimizeHuffmanTable:= GFL_TRUE;
  vSaveParam.Quality:= 100;

  gflLoadBitmapW( PWideChar( Widestring( '1.jpg' ) ), @pBmp, @vLoadParam, nil );
  gflSaveBitmapW( PWideChar( Widestring( '2.jpg' ) ), pBmp, @vSaveParam );
  // Picture had and has a width/height of 3000x2008

  gflJpegLosslessTransform( PChar( '2.jpg' ), GFL_LOSSLESS_TRANSFORM_ROTATE90 );  
  // Width/height are now 2000x3000 - this means 8 pixel rows are missing

  gflJpegLosslessTransform( PChar( '2.jpg' ), GFL_LOSSLESS_TRANSFORM_ROTATE90 );  
  // Problem continues: width/height are now 2992x2000 - another 8 pixel rows are missing

  gflJpegLosslessTransform( PChar( '2.jpg' ), GFL_LOSSLESS_TRANSFORM_ROTATE90 );  
  // Problem stopped: Width/height are now 2000x2992 - interestingly enough, now nothing has been cropped  
How does it come? Please take a look, Pierre. :(


Also: please add a Unicode version of that function, i.e. gflJpegLosslessTransformW(). Thanks :wink: