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

  • Home
  • SEARCH
  • 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 8312357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:08:07+00:00 2026-06-08T20:08:07+00:00

When I press the save button I can save only the text not the

  • 0

When I press the save button I can save only the text not the image in the JPEG format.

Html:

  <div id="painter" runat="server" style="left: 280px; position: absolute; top: 82px;
    width: 311px; height: 388px; background-color: #ccccff;">
    hi niladri
    <br />
    helo
    <br />
    dvshfgjfhglkglkhjlhkjmlkhklfhfg sasasasa
    <br />
    sssdsdsds


    <img src="image/1.jpg" alt="Osr" height="100" width="309" />
            </div>

<asp:Button ID="Save" runat="server" Style="left: 733px; position: absolute; top: 266px"
    Text="Button" OnClick="Save_Click" />

C# code:

  public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Save_Click(object sender, EventArgs e)
{
          string[] value = painter.Style.Value.Split(';');
    string hw = painter.InnerHtml;
    hw = hw.Replace("<br />", Environment.NewLine);

    string width = value[3];
    string height = value[4];
    string bgcolor = value[5];

    string[] widthArray = width.Split(':');
    string[] heightArray = height.Split(':');
    string[] bgcolorArray = bgcolor.Split(':');

    int w = int.Parse(widthArray[1].Replace("px", ""));
    int h = int.Parse(heightArray[1].Replace("px", ""));

    string color = bgcolorArray[1];

    //var overlay = new Bitmap(imagePath2);

    System.Drawing.Color c = System.Drawing.Color.Cyan;//.FromName("#ccccff");

    System.Drawing.Bitmap bt = new System.Drawing.Bitmap(w, h);
    System.Drawing.Graphics oGraphics = System.Drawing.Graphics.FromImage(bt);
    System.Drawing.Brush brush = new System.Drawing.SolidBrush(c);
    oGraphics.FillRectangle(brush, 0, 0, w, h);
    oGraphics.DrawString(hw, new Font("Arial", 12, FontStyle.Italic), SystemBrushes.WindowText, new PointF(50, 50));

    bt.Save("E:\\image10.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);  

 }
 }

Image:

Here in the attached Jpeg image, we get only the html image source information not the original image when we save into jpeg format.

  • 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-08T20:08:10+00:00Added an answer on June 8, 2026 at 8:08 pm

    Hi asked

    Use These codes:

    protected void Save_Click(object sender, EventArgs e)
    {
            string[] value = painter.Style.Value.Split(';');
            string hw = painter.InnerHtml;
            hw = hw.Replace("<br />", Environment.NewLine);
    
            string width = value[3];
            string height = value[4];
            string bgcolor = value[5];
    
            string[] widthArray = width.Split(':');
            string[] heightArray = height.Split(':');
            string[] bgcolorArray = bgcolor.Split(':');
    
            int w = int.Parse(widthArray[1].Replace("px", ""));
            int h = int.Parse(heightArray[1].Replace("px", ""));
            //=====================================================================
            //Added By RAM:
            string key = "src=";
            int start_of_img_address = hw.IndexOf(key) + key.Length+1;
            int end_of_img_address = hw.Substring(start_of_img_address + 1).IndexOf('"');
            string image_addres = hw.Substring(start_of_img_address, end_of_img_address+1);
            image_addres = Server.MapPath(image_addres);
            Image my_img = Image.FromFile(image_addres);
    
            key = "<img";
            int start_of_img_tag = hw.IndexOf(key);
            int end_of_img_tag = hw.Substring(start_of_img_tag).IndexOf('>')+1;
            string img_tag = hw.Substring(start_of_img_tag, end_of_img_tag+1);
            hw=hw.Remove(start_of_img_tag, end_of_img_tag);
            Response.Write(img_tag);
    
            //=====================================================================
            string color = bgcolorArray[1];
    
            //var overlay = new Bitmap(imagePath2);
    
            System.Drawing.Color c = System.Drawing.Color.Cyan; //.FromName("#ccccff");
    
            System.Drawing.Bitmap bt = new System.Drawing.Bitmap(w, h);
            System.Drawing.Graphics oGraphics = System.Drawing.Graphics.FromImage(bt);
            System.Drawing.Brush brush = new System.Drawing.SolidBrush(c);
            oGraphics.FillRectangle(brush, 0, 0, w, h);
            oGraphics.DrawString(hw, new Font("Arial", 12, FontStyle.Italic), SystemBrushes.WindowText, new PointF(0, 0)); //changed 50 to 0
    
            //=====================================================================
            //Added By RAM:
            oGraphics.DrawImage(my_img, 0, 170, my_img.Width, my_img.Height);
            //=====================================================================
    
            bt.Save("E:\\image10.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
    }
    

    … and Result:

    enter image description here

    EDIT:

    Also you can use Regular Expression instead of Substring, IndexOf and…

    The Regular Expression (RegEx) help you for getting:

    • Tags
    • Styles
    • And every things you want from your content

    So, read RegEx tutorials

    • Book
    • The 30 Minute Regex Tutorial
    • Example

    You must arrange the content of the final image with your own calculations.
    Good luck…

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

Sidebar

Related Questions

I'm building a CakePHP site where users can press a button to save this
SELECT works, Edit button works, but after editing, when I press Save the Grid
If I open a doc in read only mode I'm able to press save
How can I prevent my app from backgrounding? When I press the home button
I wonder how can I download/save/write a file from my server to a client's
I press login button to login into my app and I'm using asyncTask for
When I press CTRL + Space the auto completing not working. It doesn't show
I can't press any other buttons in the same window while UIScrollView is zooming
I would like to know how I can add a counter to a button
By Long Press, I mean pressing a button / panel and hold for a

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.