Modern API로 이미지 처리 강화
소개
현재 Aspose.Slides for C++ 라이브러리는 public API에서 System::Drawing의 다음 클래스에 종속됩니다:
버전 24.4부터 이 public API는 더 이상 사용되지 않음(deprecated)으로 선언되었습니다.
System::Drawing에 대한 종속성을 public API에서 제거하기 위해 “Modern API"를 추가했습니다. System::Drawing::Image 및 System::Drawing::Bitmap와 관련된 메서드는 더 이상 사용되지 않음으로 선언되었으며 Modern API의 해당 메서드로 교체해야 합니다. System::Drawing::Graphics와 관련된 메서드는 더 이상 사용되지 않음으로 선언되었고 직접적인 Modern API 대체 메서드는 없습니다.
현재 버전에서는 System::Drawing 타입에 의존하는 public API를 레거시/더 이상 사용되지 않음으로 취급하십시오. 새 코드와 기존 이미지 처리 워크플로우를 마이그레이션할 때는 Modern API를 사용하십시오.
Modern API
public API에 다음 클래스와 열거형이 추가되었습니다:
- Aspose::Slides::IImage - 래스터 또는 벡터 이미지를 나타냅니다.
- Aspose::Slides::ImageFormat - 이미지의 파일 형식을 나타냅니다.
- Aspose::Slides::Images - IImage 인터페이스를 인스턴스화하고 작업하기 위한 메서드입니다.
단일 슬라이드 또는 도형을 렌더링하려면 GetImage를 사용하십시오. 여러 프레젠테이션 슬라이드를 렌더링하려면 GetImages를 사용하십시오. 이미지를 로드하려면 Images 메서드를 사용하고, 프레젠테이션에 추가하려면 AddImage와 IImage를, 기존 프레젠테이션 이미지를 업데이트하려면 ReplaceImage와 IImage를 사용하십시오.
새 API 사용의 전형적인 시나리오는 다음과 같습니다:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>();
// 디스크에 있는 파일에서 일회용 IImage 인스턴스를 생성합니다.
System::SharedPtr<IImage> image = Images::FromFile(u"image.png");
// IImage 인스턴스를 프레젠테이션의 이미지 컬렉션에 추가하여 PowerPoint 이미지를 만듭니다.
System::SharedPtr<IPPImage> ppImage = pres->get_Images()->AddImage(image);
// 슬라이드 #1에 그림 도형을 추가합니다.
pres->get_Slide(0)->get_Shapes()->AddPictureFrame(Aspose::Slides::ShapeType::Rectangle, 10.0f, 10.0f, 100.0f, 100.0f, ppImage);
// 슬라이드 #1을 나타내는 IImage 인스턴스를 가져옵니다.
auto slideImage = pres->get_Slide(0)->GetImage(System::Drawing::Size(1920, 1080));
// 이미지를 디스크에 저장합니다.
slideImage->Save(u"slide1.jpeg", Aspose::Slides::ImageFormat::Jpeg);
구식 코드를 Modern API로 교체
전환을 용이하게 하기 위해 새로운 IImage 인터페이스는 System::Drawing::Image 및 System::Drawing::Bitmap 클래스의 별도 시그니처를 그대로 반복합니다. 일반적으로 System::Drawing을 사용하는 기존 메서드 호출을 새로운 메서드로 교체하면 됩니다.
슬라이드 썸네일 가져오기
레거시/더 이상 사용되지 않음 API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(u"pres.pptx");
pres->get_Slide(0)->GetThumbnail()->Save(u"slide1.png");
Modern API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(u"pres.pptx");
pres->get_Slide(0)->GetImage()->Save(u"slide1.png");
도형 썸네일 가져오기
레거시/더 이상 사용되지 않음 API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(u"pres.pptx");
pres->get_Slide(0)->get_Shape(0)->GetThumbnail()->Save(u"shape.png");
Modern API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(u"pres.pptx");
pres->get_Slide(0)->get_Shape(0)->GetImage()->Save(u"shape.png");
프레젠테이션 썸네일 가져오기
레거시/더 이상 사용되지 않음 API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(u"pres.pptx");
auto bitmaps = pres->GetThumbnails(System::MakeObject<RenderingOptions>(), System::Drawing::Size(1980, 1028));
for (int32_t index = 0; index < bitmaps->get_Length(); index++)
{
System::SharedPtr<System::Drawing::Bitmap> thumbnail = bitmaps[index];
thumbnail->Save(System::String::Format(u"slide_{0}.png", index), System::Drawing::Imaging::ImageFormat::get_Png());
}
Modern API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(u"pres.pptx");
auto images = pres->GetImages(System::MakeObject<RenderingOptions>(), System::Drawing::Size(1980, 1028));
for (int32_t index = 0; index < images->get_Length(); index++)
{
System::SharedPtr<IImage> thumbnail = images[index];
thumbnail->Save(System::String::Format(u"slide_{0}.png", index), Aspose::Slides::ImageFormat::Png);
}
프레젠테이션에 그림 추가
레거시/더 이상 사용되지 않음 API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>();
System::SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromFile(u"image.png");
System::SharedPtr<IPPImage> ppImage = pres->get_Images()->AddImage(image);
pres->get_Slide(0)->get_Shapes()->AddPictureFrame(Aspose::Slides::ShapeType::Rectangle, 10.0f, 10.0f, 100.0f, 100.0f, ppImage);
Modern API:
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>();
System::SharedPtr<Aspose::Slides::IImage> image = Aspose::Slides::Images::FromFile(u"image.png");
System::SharedPtr<IPPImage> ppImage = pres->get_Images()->AddImage(image);
pres->get_Slide(0)->get_Shapes()->AddPictureFrame(Aspose::Slides::ShapeType::Rectangle, 10.0f, 10.0f, 100.0f, 100.0f, ppImage);
더 이상 사용되지 않는 메서드/속성 및 Modern API 대체
Presentation 클래스
| Method Signature | Replacement Method Signature |
|---|---|
| GetThumbnails(System::SharedPtr<Export::IRenderingOptions> options) | GetImages(System::SharedPtr<Export::IRenderingOptions> options) |
| GetThumbnails(System::SharedPtr<Export::IRenderingOptions> options, System::ArrayPtr<int32_t> slides) | GetImages(System::SharedPtr<Export::IRenderingOptions> options, System::ArrayPtr<int32_t> slides) |
| GetThumbnails(System::SharedPtr<Export::IRenderingOptions> options, float scaleX, float scaleY) | GetImages(System::SharedPtr<Export::IRenderingOptions> options, float scaleX, float scaleY) |
| GetThumbnails(System::SharedPtr<Export::IRenderingOptions> options, System::ArrayPtr<int32_t> slides, float scaleX, float scaleY) | GetImages(System::SharedPtr<Export::IRenderingOptions> options, System::ArrayPtr<int32_t> slides, float scaleX, float scaleY) |
| GetThumbnails(System::SharedPtr<Export::IRenderingOptions> options, System::Drawing::Size imageSize) | GetImages(System::SharedPtr<Export::IRenderingOptions> options, System::Drawing::Size imageSize) |
| GetThumbnails(System::SharedPtr<Export::IRenderingOptions> options, System::ArrayPtr<int32_t> slides, System::Drawing::Size imageSize) | GetImages(System::SharedPtr<Export::IRenderingOptions> options, System::ArrayPtr<int32_t> slides, System::Drawing::Size imageSize) |
| Save(System::String fname, System::ArrayPtr<int32_t> slides, Export::SaveFormat format) | No Modern API replacement |
| Save(System::String fname, System::ArrayPtr<int32_t> slides, Export::SaveFormat format, System::SharedPtr<Export::ISaveOptions> options) | No Modern API replacement |
Slide 클래스
| Method Signature | Replacement Method Signature |
|---|---|
| GetThumbnail() | GetImage() |
| GetThumbnail(float scaleX, float scaleY) | GetImage(float scaleX, float scaleY) |
| GetThumbnail(System::Drawing::Size imageSize) | GetImage(System::Drawing::Size imageSize) |
| GetThumbnail(System::SharedPtr<Export::ITiffOptions> options) | GetImage(System::SharedPtr<Export::IRenderingOptions> options |
| GetThumbnail(System::SharedPtr<Export::IRenderingOptions> options) | GetImage(System::SharedPtr<Export::IRenderingOptions> options) |
| GetThumbnail(System::SharedPtr<Export::IRenderingOptions> options, float scaleX, float scaleY) | GetImage(System::SharedPtr<Export::IRenderingOptions> options, float scaleX, float scaleY) |
| GetThumbnail(System::SharedPtr<Export::IRenderingOptions> options, System::Drawing::Size imageSize) | GetImage(System::SharedPtr<Export::IRenderingOptions> options, System::Drawing::Size imageSize) |
| RenderToGraphics(System::SharedPtr<Export::IRenderingOptions> options, System::SharedPtr<System::Drawing::Graphics> graphics) | No Modern API replacement |
| RenderToGraphics(System::SharedPtr<Export::IRenderingOptions> options, System::SharedPtr<System::Drawing::Graphics> graphics, float scaleX, float scaleY) | No Modern API replacement |
| RenderToGraphics(System::SharedPtr<Export::IRenderingOptions> options, System::SharedPtr<System::Drawing::Graphics> graphics, System::Drawing::Size renderingSize) | No Modern API replacement |
Shape 클래스
| Method Signature | Replacement Method Signature |
|---|---|
| GetThumbnail() | GetImage() |
| GetThumbnail(ShapeThumbnailBounds bounds, float scaleX, float scaleY) | GetImage(ShapeThumbnailBounds bounds, float scaleX, float scaleY) |
ImageCollection 클래스
| Method Signature | Replacement Method Signature |
|---|---|
| AddImage(System::SharedPtr<System::Drawing::Image> image) | AddImage(System::SharedPtr<IImage> image) |
PPImage 클래스
| Method Signature | Replacement Method Signature |
|---|---|
| ReplaceImage(System::SharedPtr<System::Drawing::Image> newImage) | ReplaceImage(System::SharedPtr<Aspose::Slides::IImage> newImage) |
| get_SystemImage() | get_Image() |
PatternFormat 클래스
| Method Signature | Replacement Method Signature |
|---|---|
| GetTileImage(System::Drawing::Color background, System::Drawing::Color foreground) | GetTile(System::Drawing::Color background, System::Drawing::Color foreground) |
| GetTileImage(System::Drawing::Color styleColor) | GetTile(System::Drawing::Color styleColor) |
IPatternFormatEffectiveData 클래스
| Method Signature | Replacement Method Signature |
|---|---|
| GetTileImage(System::Drawing::Color background, System::Drawing::Color foreground) | GetTileIImage(System::Drawing::Color background, System::Drawing::Color foreground) |
System::Drawing::Graphics에 대한 API 지원
System::Drawing::Graphics와 관련된 메서드는 더 이상 사용되지 않음으로 선언되었으며 직접적인 Modern API 대체 메서드는 없습니다.
Modern API 이미지 렌더링 메서드를 사용하고 System::Drawing::Graphics에 렌더링하는 API 대신 사용하십시오:
- Slide::RenderToGraphics(System::SharedPtr<Export::IRenderingOptions>, System::SharedPtr<System::Drawing::Graphics>)
- Slide::RenderToGraphics(System::SharedPtr<Export::IRenderingOptions>, System::SharedPtr<System::Drawing::Graphics>, float, float)
- Slide::RenderToGraphics(System::SharedPtr<Export::IRenderingOptions>, System::SharedPtr<System::Drawing::Graphics>, System::Drawing::Size)
FAQ
System::Drawing::Graphics가 삭제된 이유는 무엇입니까?
System::Drawing::Graphics에 대한 지원은 public API에서 더 이상 사용되지 않음으로 지정되어 렌더링 및 이미지 작업을 통합하고, 플랫폼별 종속성을 제거하며, IImage를 통한 크로스 플랫폼 접근 방식으로 전환하기 위함입니다. System::Drawing::Graphics 대신 GetImage 또는 GetImages를 사용하십시오.
IImage가 System::Drawing::Image 및 System::Drawing::Bitmap에 비해 실용적인 이점은 무엇입니까?
IImage은 래스터 및 벡터 이미지를 모두 다루도록 통합하고, ImageFormat을 통해 다양한 형식으로 저장을 간소화하며, System::Drawing에 대한 의존성을 줄이고, 환경 간 코드 이식성을 높입니다.
Modern API가 썸네일 생성 성능에 영향을 미칩니까?
GetThumbnail을 GetImage로 전환해도 시나리오가 악화되지 않습니다. 새로운 메서드는 옵션 및 크기로 이미지를 생성하는 동일한 기능을 제공하며, 렌더링 옵션 지원을 유지합니다. 구체적인 이득 또는 감소는 시나리오에 따라 다르지만 기능적으로 대체 메서드는 동등합니다.