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 6339889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:44:00+00:00 2026-05-24T19:44:00+00:00

I am using following code to convert an image to Icon. Here is my

  • 0

I am using following code to convert an image to Icon.
Here is my code.

Bitmap Cbitmap=null;
  try
  {
  Cbitmap = new Bitmap("path of local image"); 
  }
  catch(Exception)
  {
  return;
  }
  Cbitmap.MakeTransparent(Color.White);
  System.IntPtr icH = Cbitmap.GetHicon();
  Icon ico = Icon.FromHandle(icH);
  Cbitmap.Dispose();
  System.IO.FileStream f = new System.IO.FileStream(Path where to save icon"" + "\\image.ico", System.IO.FileMode.OpenOrCreate);
  ico.Save(f);
   f.close();
  ico.dispose();

Now this is converted to Icon successfully but when I try to open it in image viewer it shows preview not available.

Also when to try to open it in project it says

(image.ico is not an icon file)

  • 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-05-24T19:44:02+00:00Added an answer on May 24, 2026 at 7:44 pm

    Your code is fine. It converts a JPG to an Icon. What’s the dimensions of your original JPG? If they aren’t one of the standard icon sizes, you’ll get a strange behavior. If the original JPG is too large, you’ll get the error you are seeing.

    Some of the more common sizes are 16×16, 24×24, 32×32, 48×48.

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

Sidebar

Related Questions

I'm using php and I have the following code to convert an absolute path
We try to convert from string to Byte[] using the following Java code: String
I am using the following c# code to convert an image file to a
Im using the following code to take an image, convert it to grayscale, and
I am converting Bitmap into Drawable using following code. MemoryCache memoryCache = new MemoryCache();
I am converting Base64 code to image and I am using following way to
I was just trying to convert a PPT using the following URL http://code.google.com/p/qifei/wiki/PDFConverter python
I was originally using the following code: background-image: url(../images/tabbottom.gif); background-repeat: no-repeat; background-position: left bottom;
I am using the following code to convert some Json into a dynamic object.
I have saved an image in database using following code. ofd.ShowDialog() vrPicHolder = IO.File.ReadAllBytes(ofd.FileName)

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.