スライドトランジションは、あるスライドから別のスライドに移動するときに表示される効果です。これらはプレゼンテーションのルックアンドフィールを強化し、より魅力的にします。プログラムでPowerPointファイルにスライドトランジションを追加する必要がある場合があります。そのために、この記事では、C++を使用してPowerPointスライドにトランジションを追加する方法を説明します。
- PowerPointプレゼンテーションにトランジションを追加するためのC++API
- C++を使用してスライドトランジションを追加する
- C++を使用して高度なスライドトランジションを追加する
- PowerPointプレゼンテーションでのモーフ遷移タイプの設定
PowerPointプレゼンテーションにトランジションを追加するためのC++API
Aspose.Slides for C++は、PowerPointファイルを操作するためのC++APIです。これにより、Microsoft PowerPointをインストールしなくても、PowerPointファイルを作成、読み取り、更新できます。さらに、APIを使用すると、PowerPointプレゼンテーションにスライドトランジションを追加できます。 APIは、NuGetからインストールするか、ダウンロードセクションから直接ダウンロードできます。
PM> Install-Package Aspose.Slides.Cpp
C++を使用してスライドトランジションを追加する
以下は、PowerPointプレゼンテーションにスライドトランジションを追加する手順です。
- まず、Presentationクラスを使用してPowerPointファイルをロードします。
- Presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(SlideShow::TransitionType value)メソッドを使用してスライドトランジションを設定します。
- 最後に、Presentation->Save(System::String fname, Export::SaveFormat format)メソッドを使用してプレゼンテーションを保存します。
次のサンプルコードは、C++を使用してPowerPointスライドにトランジションを追加する方法を示しています。
// ファイルパス
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddTransition_out.pptx";
// プレゼンテーションファイルをロードする
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// スライド1に円タイプのトランジションを適用します
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// スライド2にコームタイプのトランジションを適用します
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// プレゼンテーションを保存
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
C++を使用して高度なスライドトランジションを追加する
以下は、C++を使用してスライドに高度なトランジションを追加する手順です。
- まず、Presentationクラスを使用してPowerPointファイルをロードします。
- ISlideShowTransitionクラスを使用して、遷移タイプとその他の遷移効果を設定します。
- 最後に、Presentation->Save(System::String fname, Export::SaveFormat format)メソッドを使用してプレゼンテーションを保存します。
次のサンプルコードは、C++を使用して高度なスライドトランジションを追加する方法を示しています。
// ファイルパス
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddAdvancedTransition_out.pptx";
// プレゼンテーションファイルをロードする
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// スライド1に円タイプのトランジションを適用します
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Circle);
// 遷移時間を3秒に設定します
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceOnClick(true);
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_AdvanceAfterTime(3000);
// スライド2にコームタイプのトランジションを適用します
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Comb);
// 遷移時間を5秒に設定します
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceOnClick(true);
presentation->get_Slides()->idx_get(1)->get_SlideShowTransition()->set_AdvanceAfterTime(5000);
// プレゼンテーションを保存
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
PowerPointプレゼンテーションでのモーフ遷移タイプの設定
モーフトランジションは、スライド間のスムーズなトランジションアニメーションを作成するためにプレゼンテーションで使用されます。次のセクションでは、Microsoft PowerPointで、およびプログラムでC++を使用してモーフ遷移を追加する方法について説明します。
Microsoft PowerPointでモーフ遷移を設定する
以下は、Microsoft PowerPointでモーフトランジションを追加する手順です。
- [トランジション]タブを開きます。
- モーフ遷移タイプを選択します。
- トランジションエフェクトを選択するには、[トランジション]タブの[エフェクトオプション]を選択します。
C++を使用してPowerPointプレゼンテーションでモーフ遷移を設定する
Microsoft PowerPointと同様に、Aspose.Slides for C++ APIは、次のモーフ遷移効果を提供します。
- ByObject: Morph transition will be performed considering shapes as indivisible objects.
- ByWord: Morph transition will be performed by transferring text by words where possible.
- ByChar: Morph transition will be performed by transferring text by characters where possible.
以下は、C++を使用してPowerPointプレゼンテーションでモーフ遷移を設定する手順です。
- Presentationクラスを使用してPowerPointファイルをロードします。
- 遷移タイプをmorphに設定します。
- IMorphTransition->set_MorphType(TransitionMorphType value)メソッドを使用して、モーフ遷移効果を設定します。
- Presentation->Save(System::String fname, Export::SaveFormat format)メソッドを使用してプレゼンテーションを保存します。
次のサンプルコードは、C++を使用してPowerPointプレゼンテーションでモーフトランジションを設定する方法を示しています。
// ファイルパス
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\AddMorphTransition_out.pptx";
// プレゼンテーションファイルをロードする
auto presentation = System::MakeObject<Presentation>(sourceFilePath);
// モーフ遷移を追加
presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->set_Type(Aspose::Slides::SlideShow::TransitionType::Morph);
auto morphTransition = System::DynamicCast<Aspose::Slides::SlideShow::IMorphTransition>(presentation->get_Slides()->idx_get(0)->get_SlideShowTransition()->get_Value());
morphTransition->set_MorphType(Aspose::Slides::SlideShow::TransitionMorphType::ByWord);
// プレゼンテーションを保存
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
無料ライセンスを取得する
評価制限なしでAPIを試すために、無料の一時ライセンスをリクエストできます。
結論
この記事では、C++を使用してPowerPointプレゼンテーションにスライドトランジションを追加する方法を学習しました。さらに、Aspose.Slides for C++ APIを使用して、PowerPointスライドにモーフトランジションを追加する方法を見てきました。これは、PowerPointファイルを操作するための多数の追加機能を提供する堅牢で機能豊富なAPIです。 公式ドキュメントにアクセスすると、APIの詳細を調べることができます。ご不明な点がございましたら、無料サポートフォーラムまでお気軽にお問い合わせください。