Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

 

The following Code loads a photo, resizes it, and then copies it to the cache.

Background: in the code, you want to load a photo in Word using the Word addin. Before it is pasted into the Word document, the photo is resized at run time, and then saved to the Word clipboard for further processing.

 

 

       public static void load_Photo_compressed_to_Clipboard(string input_Image_Path, int setLength)

        {

            //---------------< Image_resize() >---------------

            Bitmap source_Bitmap = new Bitmap(input_Image_Path);

 

            double dblWidth_origial = source_Bitmap.Width;

            double dblHeigth_origial = source_Bitmap.Height;

 

            //< check orientation >

            bool IsOrientation_Horizontal = (dblWidth_origial > dblHeigth_origial) ? true : false;

            //</ check orientation >

 

            int new_Height = 0;

            int new_Width = 0;

            double zoom_factor = 1;

            if (IsOrientation_Horizontal == true)

            {

                new_Width = setLength;

                zoom_factor = new_Width / dblWidth_origial;

                new_Height = (int)(dblHeigth_origial * zoom_factor);

            }

            else

            {

                new_Height = setLength;

                zoom_factor = new_Height / dblHeigth_origial;

                new_Width = (int)(dblWidth_origial * zoom_factor);

            }

 

            Image outImage = new Bitmap(source_Bitmap, new_Width, new_Height);

            var t = new Thread((ThreadStart)(() =>

            {

                Clipboard.SetImage(outImage);

            }));

            t.SetApartmentState(ApartmentState.STA);

            t.Start();

            t.Join();

 

            //---------------</ Image_resize() >---------------

        }

 

 

C# Code

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Mobile
»
Resize the photo and copy it to the clipboard
»
Code: Word Addin with photos resize and paste in Word
»
How to Get the Word Template or a New Word Document in VSTO Addin
»
Word Addin: Adds customer data from Excel file to Word file
»
Saving Settings in Office Addin VSTO
»
Word: Loop through all the words in a Word document
»
Load data grid in C #. Example here in WinForms, VSTO add-in

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de