Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9236465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:17:57+00:00 2026-06-18T07:17:57+00:00

My code: private void CreateAnimatedGif(List<string> GifsFilesRadar , List<string> GifsFilesSatellite)//string FileName1 , string FileName2) {

  • 0

My code:

private void CreateAnimatedGif(List<string> GifsFilesRadar , List<string> GifsFilesSatellite)//string FileName1 , string FileName2)
{
    Bitmap bitmap = null;
    DirectoryInfo inf = new DirectoryInfo(tempGifFiles);
    FileInfo[] fi = inf.GetFiles("*.gif");
    for (int i = 0; i < fi.Length; i++)
    {
        Bitmap file1 = new Bitmap(GifsFilesRadar[i]);
        Bitmap file2 = new Bitmap(GifsFilesSatellite[i]);
        //calculate the new width proportionally to the new height it will have
        int newWidth = file1.Width + file1.Width / (file2.Height / (file2.Height - file1.Height));

        bitmap = new Bitmap(newWidth + file2.Width, Math.Max(file1.Height, file2.Height));
        using (Graphics g = Graphics.FromImage(bitmap))
        {
            //high quality rendering and interpolation mode
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;

            //resize the left image
            g.DrawImage(file1, new Rectangle(0, 0, newWidth, file2.Height));
            g.DrawImage(file2, newWidth, 0);
            string t = @"d:\GifsForAnimations" + "\\" + i.ToString("D6") + ".Gif";
            bitmap.Save(t, System.Drawing.Imaging.ImageFormat.Gif);
            if (i == 4)
            {
                break;
            }
        }
    }
    List<string> gif = new List<string>();
    DirectoryInfo info = new DirectoryInfo(@"d:\GifsForAnimations");
    FileInfo[] finfo = info.GetFiles();
    for (int i = 0; i < finfo.Length; i++)
    {
        gif.Add(finfo[i].FullName);
    }
    newFile.MakeGIF(gif, @"d:\newGifAnim.gif", 80, true);
}

In the end I have new animated gif file.
Now I have the border and these are the locations:

  • Bottom left corner: 232.0,408.0
  • Top left corner: 232.0,211.0
  • Top right corner: 524.0,211.0
  • Bottom right corner: 524.0,408.0

I want to add on each image a frame around it to mark the border around. Let’s say the border will be in Red and the border line size will be 5 pixels.

How can I create the rectangle around existing bitmap or gif file ?
It doesn’t have to be connected to my example code here but how do I create the frame/border around the image with the locations I have ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:17:58+00:00Added an answer on June 18, 2026 at 7:17 am

    You could add this line after g.DrawImage(file2, newWidth, 0);

    g.DrawRectangle(new Pen(Brushes.Red, 5), new Rectangle(0, 0, newWidth, file2.Height));
    

    Here is a small test method so you can see it working

        private void button1_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = new Bitmap(@"C:\avatar63.jpg");
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.DrawRectangle(new Pen(Brushes.Red, 5), new Rectangle(0, 0, bitmap.Width, bitmap.Height));
            }
            bitmap.Save(@"C:\avatar63New.jpg");
        }
    

    Before: enter image description here After: enter image description here

    You can add the rectagle anywhere you want, tou jst need to supply the X,Y,Width,Height

    g.DrawRectangle(new Pen(Brushes.LimeGreen, 5), new Rectangle(50, 50, 100, 100));
    

    Using your 4 point structure this should work

       Point topLeft = new Point(232,211 );
       Point topRightr = new Point(232, 408);
       Point bottomLeft = new Point(524, 211);
       Point bottomRight = new Point(524, 408);
    
       g.DrawRectangle(new Pen(Brushes.LimeGreen, 5), new Rectangle(topLeft, new Size(topRightr.X - topLeft.X, bottomLeft.Y - topLeft.Y)));
    
      // TopLeft = rectangle location
      // TopRight.X - TopLeft.X = Width of rectangle
      // BottomLeft.Y - TopLeft.Y = height of rectangle
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this code: private void CreateAnimatedGif(string FileName1 , string FileName2) { Bitmap file1
This is the code: private void button1_Click(object sender, EventArgs e) { List<string> user =
I have this code: private void test(List<string> a) { } I want to use
I have this code private void saveImage() { Bitmap bmp1 = new Bitmap(pictureBox.Image); bmp1.Save(c:\\t.jpg,
I have the following code: private void _DoValidate(object sender, DoWorkEventArgs e) { this.BeginInvoke(new MethodInvoker(()
I have this code private void writeReport(IReport report, string reportName) { string reportString =
this is my code private void sendToClient(Dictionary<string, string> reportDic) { Response.Clear(); Response.BufferOutput = false;
I have the following code: private void WatchFileForChanges() { if (fileInfo.Directory != null) {
When I run the following code: private void button1_Click(object sender, EventArgs e) { Bitmap
The code: private void checkBox2_CheckedChanged(object sender, EventArgs e) { crawlLocaly1 = new CrawlLocaly(); crawlLocaly1.StartPosition

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.