How to set background color when converting images to video slideshow with Image To Video SDK - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to set background color when converting images to video slideshow with Image To Video SDK

  • Home
  • /
  • Articles
  • /
  • How to set background color when converting images to video slideshow with Image To Video SDK

Bytescout Image To Video SDK converts set of JPG, PNG, BMP images to AVI or WMV video slideshow and allows to set background color for the slideshow.

The sample codes below demonstrate how to set background color for a video slideshow during conversion in VB.NET and C#.

Visual Basic .NET

Imports BytescoutImageToVideoLib

Module Module1

Sub Main()

Console.WriteLine("Converting JPG slides into video, please wait..")

' Create BytescoutImageToVideoLib.ImageToVideo object instance
Dim converter As ImageToVideo = New ImageToVideo()

' Activate the component
converter.RegistrationName = "demo"
converter.RegistrationKey = "demo"

' set default in effect for slides (you can also set effects for each single slide)
converter.Slides.DefaultSlideInEffect = 1 ' teFadeIn (1) - fades in effect for slides transition
converter.Slides.DefaultSlideInEffectDuration = 500 ' 500 msec for in effect

' Set movie background color
converter.SetBackgroundColorRGB(0, 255, 128)

' Add images and set slide durations
Dim slide As Slide
slide = CType(converter.AddImageFromFileName("........slide1.jpg"), Slide)

slide.Duration = 3000 ' 3000ms = 3s
slide = CType(converter.AddImageFromFileName("........slide2.jpg"), Slide)

slide.Duration = 3000
slide = CType(converter.AddImageFromFileName("........slide3.jpg"), Slide)

slide.Duration = 3000

' Set output video size
converter.OutputWidth = 500

converter.OutputHeight = 400

' Set output video file name
converter.OutputVideoFileName = "result.wmv"

' Run the conversion
converter.RunAndWait()

Console.WriteLine("Conversion is done. Press any key to continue...")

Console.ReadKey

' Open the result video file in default media player
Process.Start("result.wmv")

End Sub

End Module 

Visual C#

using System;
using System.Diagnostics;

using BytescoutImageToVideoLib;

namespace BackgroundColor
{
class Program
{

static void Main(string[] args)
{

Console.Write("Converting JPG slides into video, please wait..");

// Create BytescoutImageToVideoLib.ImageToVideo object instance
ImageToVideo converter = new ImageToVideo();

// Activate the component
converter.RegistrationName = "demo";
converter.RegistrationKey = "demo";

// Set movie background color
converter.SetBackgroundColorRGB(0, 255, 128);

// Add images and set slide durations
Slide slide;
slide = (Slide) converter.AddImageFromFileName("..\..\..\..\slide1.jpg");

slide.Duration = 3000; // 3000ms = 3s
slide = (Slide) converter.AddImageFromFileName("..\..\..\..\slide2.jpg");

slide.Duration = 3000;
slide = (Slide) converter.AddImageFromFileName("..\..\..\..\slide3.jpg");

slide.Duration = 3000;

// Set output video size
converter.OutputWidth = 500;

converter.OutputHeight = 400;

// Set output video file name
converter.OutputVideoFileName = "result.wmv";

Console.WriteLine("Conversion is done. Press any key to continue..");
Console.ReadKey();

// Run the conversion
converter.RunAndWait();

// Open the result video file in default media player

Process.Start("result.wmv");
}
}

} 

Download output video file: result.zip (extract and run result.wmv to see the conversion sample)

Tutorials:

prev
next