Page 1 of 1

gflSaveBitmapW() + gflJpegLosslessTransform() = crop

Posted: Sun Oct 31, 2010 1:59 am
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

  vLoadParam: GFL_LOAD_PARAMS;
  vSaveParam: GFL_SAVE_PARAMS;
  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: