Bitmap Error! RRS feed

  • Question

  • User183689629 posted
    Hi guys,

    I need some urgent help here. I am loading images on fly in a Bitmap object and extracting details like height and width for further calculations. 

    <%@ import namespace="system.drawing.imaging" %>

    dim ImgObj as Bitmap
    <%@ import namespace="System.Drawing.Imaging"%>
    The above declaration and code works beautifully when running on my local machine, however as soon as I upload it to the remote webserver, it comes back saying with the following error :

    BC30002: Type 'Bitmap' is not defined

    I would highly appreciate any help.

    Thursday, June 30, 2005 4:56 AM

All replies

  • User-1029435529 posted
    The Bitmap class is within the System.Drawing namespace, not the System.Drawing.Imaging namespace.
    Thursday, June 30, 2005 5:05 AM
  • User183689629 posted


    Thanks for that!! it certainly helped me!! Another problem now .... I can now arrange all the images as per height, however while showing on the screen, I actually fix the width to 30 and that propotionally rearranges the height as well!!!

    This change gets out of synchronization with my algorithm as at times a large image seems smaller than the other when its suppressed. Now I am wondering that is there any method or way, I can find out what will be the height if I change the width?.



    Thursday, June 30, 2005 10:27 AM
  • User-1029435529 posted

    Now I am wondering that is there any method or way, I can find out what will be the height if I change the width?
    That is just a matter of mathematics.

    I've uploaded a sample for you at the following address:

    Here is the source of that page. Most of the code just deals with the page itself, so I have highlighted the code that deals with finding the scale of the thumbnail.

    <%@ Page Language="C#" %>
    <script runat="server">

        int originalWidth;    // width of the original, full-sized image
        int originalHeight;   // height of the original, full-sized image
        int maxThumbWidth;    // maximum width of the thumbnail
        int maxThumbHeight;   // maximum height of the thumbnail
        int thumbWidth;       // width of the resized, thumbnail image
        int thumbHeight;      // height of the resized, thumbnail image
        private void Page_Load(object sender, EventArgs e)
            if (Page.IsPostBack
                && MaxWidthTextbox.Text.Length > 0
                && MaxHeightTextbox.Text.Length > 0)
                maxThumbWidth = Convert.ToInt32(MaxWidthTextbox.Text);
                maxThumbHeight = Convert.ToInt32(MaxHeightTextbox.Text);
                // set the default maximum width and height of the thumbnail
                maxThumbWidth = 200;
                maxThumbHeight = 200;
                MaxWidthTextbox.Text = maxThumbWidth.ToString();
                MaxHeightTextbox.Text = maxThumbHeight.ToString();
            // show the thumbnail area

        private void ImageResize_Click(object sender, EventArgs e)
            // Quick validation
            if (OriginalWidthTextbox.Text.Length == 0
                || OriginalHeightTextbox.Text.Length == 0)
            // get the width and the height of the original, full-sized image   
            originalWidth = Convert.ToInt32(OriginalWidthTextbox.Text);
            originalHeight = Convert.ToInt32(OriginalHeightTextbox.Text);
            // this is the value we are trying to determine:
            // what scale needs to be applied to get from the original, full-sized image
            // to a thumbnail that is no larger than the maximum thumbnail width and height
            double scale;
            // do we need to scale this at all?
            if ((originalWidth < maxThumbWidth) && (originalHeight < maxThumbHeight))
                scale = 1;
                // if scaled by width
                double deltaW = maxThumbWidth/Convert.ToDouble(originalWidth);
                // if scaled by height
                double deltaH = maxThumbHeight/Convert.ToDouble(originalHeight);
                // use the smaller scale value
                scale = (deltaW < deltaH)? deltaW : deltaH;
            thumbWidth = Convert.ToInt32(scale * originalWidth);
            thumbHeight = Convert.ToInt32(scale * originalHeight);
        private void UpdateDisplay(bool showThumb)
            MaxThumbnail.Width = Unit.Pixel(maxThumbWidth);
            MaxThumbnail.Height = Unit.Pixel(maxThumbHeight);
            Result.Text = "Max Size: " + maxThumbWidth + "w x " + maxThumbHeight + "h";
            if (showThumb)
                Result.Text += "<br />Thumbnail: " + thumbWidth + "w x " + thumbHeight + "h";
                Thumbnail.Width = Unit.Pixel(thumbWidth);
                Thumbnail.Height = Unit.Pixel(thumbHeight);
                Thumbnail.Visible = true;

    <form runat="server">
        Size of original:
        <asp:Textbox id="OriginalWidthTextbox" style="width:40px" runat="server" />width x
        <asp:Textbox id="OriginalHeightTextbox"  style="width:40px" runat="server" />height
        <br />
        Maximum size of thumbnail:
        <asp:Textbox id="MaxWidthTextbox" style="width:40px" runat="server" />width x
        <asp:Textbox id="MaxHeightTextbox"  style="width:40px" runat="server" />height
        <br />
        <asp:Button id="ImageResize" text="Find Thumbnail Dimensions" onclick="ImageResize_Click" runat="server" />
        <br />
        <asp:Panel id="Display" runat="server" style=";top:120px;left:120px;">
            <asp:Panel id="MaxThumbnail" runat="server" style="border:solid 1px #ccc;">
                <asp:Panel id="Thumbnail" visible="false" runat="server" style="background:green;font-size:1px;" />
            <asp:Label id="Result" runat="server" />

    Thursday, June 30, 2005 11:43 PM