Jump to content


Photo

Tiff multipage


  • Please log in to reply
2 replies to this topic

#1 luvac

luvac

    Newbie

  • Miembros
  • Pip
  • 1 posts

Posted 10 June 2014 - 10:24 AM

Que tal señores alguien a trabajado con Tiff multipaginas,he leido el tema de escafandra para leer tiff con gdi pero solo lee la primera imagen como hago para que lea las otras?
  • 0

#2 Rolphy Reyes

Rolphy Reyes

    Advanced Member

  • Moderadores
  • PipPipPip
  • 2092 posts
  • LocationRepública Dominicana

Posted 10 June 2014 - 02:04 PM

Saludos.

Hace un tiempo pude leer TIFF de múltiples paginas con el componente ImageEn.
  • 0

#3 escafandra

escafandra

    Advanced Member

  • Administrador
  • 4111 posts
  • LocationMadrid - España

Posted 11 June 2014 - 05:41 PM

Prueba con esta función que acabo de escribir:



delphi
  1. type
  2.  
  3. function GdiplusStartup(var GdiToken: DWORD; Startup, Output: PBYTE): DWORD; stdcall external 'gdiplus';
  4. function GdipCreateBitmapFromFile(lpFileName: PWCHAR; var GBitmap: THANDLE): DWORD; stdcall external 'gdiplus';
  5. function GdipCreateHBITMAPFromBitmap(GBitmap: THANDLE; var hBitmap: HBITMAP; BKColor: DWORD): DWORD; stdcall external 'gdiplus';
  6. procedure GdiplusShutdown(GdiToken: DWORD); stdcall external 'gdiplus';
  7. function GdipImageGetFrameDimensionsList(image: THANDLE; var dimensionIDs: TGUID; count: DWORD): DWORD; stdcall external 'gdiplus';
  8. function GdipImageGetFrameCount(image: THANDLE; var dimensionID: TGUID; var count: DWORD): DWORD; stdcall external 'gdiplus';
  9. function GdipImageSelectActiveFrame(image: THANDLE; var dimensionID: TGUID; frameIndex: DWORD): DWORD; stdcall external 'gdiplus';
  10.  
  11. implementation
  12.  
  13. function CreateHBITMAPFromFilePage(cFileName: PCHAR; Index: DWORD): HBITMAP;
  14. var
  15.   FileName: array of WCHAR;
  16.   size: integer;
  17.   gdiplusToken: DWORD;
  18.   GdiPlusStartupInput: array[0..2] of int64;
  19.   GBitmap: THANDLE;
  20.   DimensionID: TGUID;
  21.   Frames: DWORD;
  22. begin
  23.   Result:= 0;
  24.  
  25.   // Pasamos a Unicode
  26.   SetLength(FileName, lstrlen(cFileName)+1);
  27.   size:= lstrlen(cFileName)*sizeof(WCHAR)+1;
  28.   MultiByteToWideChar(CP_ACP, 0, cFileName, -1, @FileName[0], size);
  29.  
  30.   // Inicializamos GDI+.
  31.   GdiPlusStartupInput[0]:= 1; GdiPlusStartupInput[1]:= 0;
  32.   if GdiplusStartup(gdiplusToken, @GdiPlusStartupInput, nil) = 0 then
  33.   begin
  34.     GdipCreateBitmapFromFile(PWCHAR(FileName), GBitmap);
  35.     GdipImageGetFrameDimensionsList(GBitmap, dimensionID, 1);
  36.     GdipImageGetFrameCount(GBitmap, dimensionID, Frames);
  37.     GdipImageSelectActiveFrame(GBitmap, dimensionID, Index mod Frames);
  38.     GdipCreateHBITMAPFromBitmap(GBitmap, Result, 0);
  39.  
  40.     // Cerramos GDI+
  41.     GdiplusShutdown(gdiplusToken);
  42.   end;
  43. end;



Ejemplo de uso:


delphi
  1. Image1.Picture.Bitmap.Handle:= CreateHBITMAPFromFilePage('Fax1.TIF', 4);




Saludos.
  • 0




IP.Board spam blocked by CleanTalk.