แปลงงานนำเสนอ PowerPoint เป็น TIFF ด้วย C++

บทนำ

TIFF (Tagged Image File Format) เป็นรูปแบบภาพเรสเตอร์แบบไม่มีการสูญเสียข้อมูลที่ใช้กันอย่างกว้างขวางและเป็นที่รู้จักในคุณภาพที่ยอดเยี่ยมและการรักษารายละเอียดของกราฟิกอย่างละเอียด นักออกแบบ ช่างภาพ และผู้จัดพิมพ์บนเดสก์ท็อปมักเลือกใช้ TIFF เพื่อคงรักษาชั้น สีที่แม่นยำ และการตั้งค่าเดิมของภาพ

ด้วย Aspose.Slides คุณสามารถแปลงสไลด์ PowerPoint (PPT, PPTX) และสไลด์ OpenDocument (ODP) เป็นภาพ TIFF ที่มีคุณภาพสูงได้อย่างง่ายดาย ทำให้การนำเสนอของคุณคงความคมชัดสูงสุด

แปลงการนำเสนอเป็น TIFF

โดยใช้เมธอด Save ที่มาจากคลาส Presentation คุณสามารถแปลงการนำเสนอ PowerPoint ทั้งหมดเป็น TIFF ได้อย่างรวดเร็ว ภาพ TIFF ที่ได้จะสอดคล้องกับขนาดสไลด์ค่าเริ่มต้น

#include <DOM/Presentation.h>
#include <Export/SaveFormat.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;

// สร้างอินสแตนซ์ของคลาส Presentation ที่แทนไฟล์การนำเสนอ (PPT, PPTX, ODP ฯลฯ).
auto presentation = MakeObject<Presentation>(u"Demo_File.pptx");

// Save the presentation as TIFF.
presentation->Save(u"Output.tiff", SaveFormat::Tiff);

presentation->Dispose();

แปลงการนำเสนอเป็น TIFF ขาว-ดำ

เมธอด set_BwConversionMode ในคลาส TiffOptions ให้คุณระบุอัลกอริธึมที่ใช้เมื่อแปลงสไลด์หรือภาพสีเป็น TIFF ขาว-ดำ โปรดทราบว่าการตั้งค่านี้ใช้ได้เฉพาะเมื่อเมธอด set_CompressionType ถูกตั้งค่าเป็น CCITT4 หรือ CCITT3

สมมติว่าเรามีไฟล์ “sample.pptx” ที่มีสไลด์ดังต่อไปนี้:

สไลด์การนำเสนอ

โค้ด C++ นี้แสดงวิธีแปลงสไลด์สีเป็น TIFF ขาว-ดำ:

#include <DOM/Presentation.h>
#include <Export/BlackWhiteConversionMode.h>
#include <Export/SaveFormat.h>
#include <Export/TiffCompressionTypes.h>
#include <Export/TiffOptions.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;

auto tiffOptions = MakeObject<TiffOptions>();
tiffOptions->set_CompressionType(TiffCompressionTypes::CCITT4);
tiffOptions->set_BwConversionMode(BlackWhiteConversionMode::Dithering);

auto presentation = MakeObject<Presentation>(u"sample.pptx");
presentation->Save(u"output.tiff", SaveFormat::Tiff, tiffOptions);

presentation->Dispose();

ผลลัพธ์:

TIFF ขาว-ดำ

แปลงการนำเสนอเป็น TIFF พร้อมขนาดกำหนดเอง

หากต้องการภาพ TIFF ที่มีขนาดเฉพาะคุณสามารถตั้งค่าที่ต้องการโดยใช้เมธอดที่มีใน TiffOptions ตัวอย่างเช่นเมธอด set_ImageSize จะให้คุณกำหนดขนาดของภาพผลลัพธ์

#include <DOM/Presentation.h>
#include <Export/NotesCommentsLayoutingOptions.h>
#include <Export/NotesPositions.h>
#include <Export/SaveFormat.h>
#include <Export/TiffCompressionTypes.h>
#include <Export/TiffOptions.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;

// สร้างอินสแตนซ์ของคลาส Presentation ที่แทนไฟล์การนำเสนอ (PPT, PPTX, ODP ฯลฯ).
auto presentation = MakeObject<Presentation>(u"sample.pptx");

auto tiffOptions = MakeObject<TiffOptions>();

// ตั้งค่าชนิดการบีบอัด.
tiffOptions->set_CompressionType(TiffCompressionTypes::Default);
/*
ประเภทการบีบอัด:
    Default - ระบุโครงสร้างการบีบอัดเริ่มต้น (LZW).
    None - ระบุว่าไม่มีการบีบอัด.
    CCITT3
    CCITT4
    LZW
    RLE
*/

// ความลึกขึ้นอยู่กับชนิดการบีบอัดและไม่สามารถตั้งค่าได้ด้วยตนเอง.

// ตั้งค่า DPI ของภาพ.
tiffOptions->set_DpiX(200);
tiffOptions->set_DpiY(200);

// ตั้งค่าขนาดของภาพ.
tiffOptions->set_ImageSize(System::Drawing::Size(1728, 1078));

auto notesOptions = MakeObject<NotesCommentsLayoutingOptions>();
notesOptions->set_NotesPosition(NotesPositions::BottomFull);
tiffOptions->set_SlidesLayoutOptions(notesOptions);

// บันทึกการนำเสนอเป็น TIFF ด้วยขนาดที่ระบุ.
presentation->Save(u"custom_size.tiff", SaveFormat::Tiff, tiffOptions);

presentation->Dispose();

แปลงการนำเสนอเป็น TIFF พร้อมรูปแบบพิกเซลของภาพกำหนดเอง

โดยใช้เมธอด set_PixelFormat จากคลาส TiffOptions คุณสามารถระบุรูปแบบพิกเซลที่ต้องการสำหรับภาพ TIFF ที่ได้

#include <DOM/Presentation.h>
#include <Export/ImagePixelFormat.h>
#include <Export/SaveFormat.h>
#include <Export/TiffOptions.h>
#include <system/smart_ptr.h>
using namespace Aspose::Slides;
using namespace Aspose::Slides::Export;
using namespace System;

// สร้างอินสแตนซ์ของคลาส Presentation ที่แทนไฟล์การนำเสนอ (PPT, PPTX, ODP ฯลฯ).
auto presentation = MakeObject<Presentation>(u"Demo_File.pptx");

auto tiffOptions = MakeObject<TiffOptions>();

tiffOptions->set_PixelFormat(ImagePixelFormat::Format8bppIndexed);
/*
ImagePixelFormat มีค่าต่อไปนี้ (ตามที่ระบุในเอกสาร):
    Format1bppIndexed - 1 บิตต่อพิกเซล, แบบดัชนี.
    Format4bppIndexed - 4 บิตต่อพิกเซล, แบบดัชนี.
    Format8bppIndexed - 8 บิตต่อพิกเซล, แบบดัชนี.
    Format24bppRgb    - 24 บิตต่อพิกเซล, RGB.
    Format32bppArgb   - 32 บิตต่อพิกเซล, ARGB.
*/

// บันทึกการนำเสนอเป็น TIFF ด้วยขนาดภาพที่ระบุ.
presentation->Save(u"Custom_Image_Pixel_Format.tiff", SaveFormat::Tiff, tiffOptions);

presentation->Dispose();

คำถามที่พบบ่อย

ฉันสามารถแปลงสไลด์เดี่ยวแทนการแปลงการนำเสนอ PowerPoint ทั้งหมดเป็น TIFF ได้หรือไม่?

ใช่ Aspose.Slides รองรับการแปลงสไลด์เดี่ยวจากการนำเสนอ PowerPoint หรือ OpenDocument เป็นภาพ TIFF แยกต่างหาก

มีขีดจำกัดใด ๆ เกี่ยวกับจำนวนสไลด์เมื่อแปลงการนำเสนอเป็น TIFF หรือไม่?

ไม่มี Aspose.Slides ไม่จำกัดจำนวนสไลด์ คุณสามารถแปลงการนำเสนอขนาดใดก็ได้เป็นรูปแบบ TIFF

แอนิเมชันและเอฟเฟกต์การเปลี่ยนของ PowerPoint จะถูกเก็บไว้เมื่อแปลงสไลด์เป็น TIFF หรือไม่?

ไม่ TIFF เป็นรูปแบบภาพนิ่ง ดังนั้นแอนิเมชันและเอฟเฟกต์การเปลี่ยนจะไม่ถูกเก็บไว้ มีเพียงภาพนิ่งของสไลด์ที่ถูกส่งออกเท่านั้น