Click here to Skip to main content
15,895,423 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Opening word/pdf document in another window Pin
indian1431-Mar-16 6:08
indian1431-Mar-16 6:08 
GeneralRe: Opening word/pdf document in another window Pin
indian1431-Mar-16 6:22
indian1431-Mar-16 6:22 
GeneralRe: Opening word/pdf document in another window Pin
Blikkies1-Mar-16 19:48
professionalBlikkies1-Mar-16 19:48 
GeneralRe: Opening word/pdf document in another window Pin
indian1432-Mar-16 15:18
indian1432-Mar-16 15:18 
AnswerRe: Opening word/pdf document in another window Pin
Blikkies29-Feb-16 22:09
professionalBlikkies29-Feb-16 22:09 
QuestionResizing Images, from Bytes[] back to bytes[] Pin
jkirkerx29-Feb-16 10:47
professionaljkirkerx29-Feb-16 10:47 
AnswerRe: Resizing Images, from Bytes[] back to bytes[] [I think its solved] Pin
jkirkerx29-Feb-16 11:45
professionaljkirkerx29-Feb-16 11:45 
General[Now it works], but needs advice on disposing Pin
jkirkerx29-Feb-16 12:51
professionaljkirkerx29-Feb-16 12:51 
I case your reading this, to figure out how to do it, this is what worked for me, but it needs more refinement such as disposing.

So I guess I'm down to just disposing of the object, but I need to make sure I preserve 1 of them to pass back to the Controller.
public static model_image_object smtpHeader_resize(string pName, byte[] pBytes)
{
    // Target Width / Height
    // Headers are 650px in width, and suppose to be 146px in height
    const int t_Width = 650;
    const int t_Height = 146;

    // Create the return Image Object
    model_image_object pResult = new model_image_object();
    Stream stream_in = new MemoryStream(pBytes);
    MemoryStream ms_out = new MemoryStream();

    // Create an Image so we can get the image parameters
    Image image_in = Image.FromStream(stream_in);

    // Write this to the drive and visually inspect it
    image_in.Save(System.Web.HttpContext.Current.Server.MapPath("~/Images/smtp/image_in.png"));

    // Figure out what we need to do to resize this image
    int oWidth = image_in.Width;
    int oHeight = image_in.Height;
    int cHeight = 0;
    int cWidth = 0;

    // Create the canvas for the new resized image
    Bitmap bitmapObj = new Bitmap(t_Width, t_Height, PixelFormat.Format24bppRgb);            

    // Create the new graphics, that will overlay the Bitmap Canvas
    using (Graphics graphicObj = Graphics.FromImage(bitmapObj))
    {
        graphicObj.Clear(Color.Transparent);
        graphicObj.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
        graphicObj.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

        // Calculate the new Height and Width of the Image
        if (oWidth > t_Width)
        {
            cWidth = t_Width;
            cHeight = (int)Math.Round((oHeight / (float)oWidth) * t_Width);
        }
        else if (oHeight > t_Height)
        {
            cHeight = t_Height;
            cWidth = (int)Math.Round((oWidth / (float)oHeight) * t_Height);
        }

        // Calculate how to overlay the width of the image centered
        int x = (cWidth - t_Width) / 2;
        int y = (cHeight - t_Height) / 2;

        // Create the new Image Object
        graphicObj.DrawImage(image_in, x, y, t_Width, t_Height);
        graphicObj.Save();
    }            

    // Now write the image_out to test it and make sure it's correct<br />
    bitmapObj.Save(System.Web.HttpContext.Current.Server.MapPath("~/Images/smtp/bitmap_out.png"));

    // Create a new MemoryStream to Save the Image to
    bitmapObj.Save(ms_out, ImageFormat.Png);            

    // Program the pResult
    pResult.Data = ms_out.ToArray();
    pResult.Name = pName;
    pResult.Type = "image/png";
    pResult.Size = new model_image_type_size();
    pResult.Size.Height = cHeight;
    pResult.Size.Width = cWidth;

    return pResult;
    }        

}

QuestionAn Ajax Control is working on local machine not working on Server when deployed Pin
indian14327-Feb-16 14:32
indian14327-Feb-16 14:32 
AnswerRe: An Ajax Control is working on local machine not working on Server when deployed Pin
Nathan Minier29-Feb-16 1:36
professionalNathan Minier29-Feb-16 1:36 
GeneralRe: An Ajax Control is working on local machine not working on Server when deployed Pin
indian14329-Feb-16 11:10
indian14329-Feb-16 11:10 
QuestionASP.Net Pin
Member 1235142825-Feb-16 3:05
Member 1235142825-Feb-16 3:05 
AnswerRe: ASP.Net Pin
ZurdoDev25-Feb-16 4:09
professionalZurdoDev25-Feb-16 4:09 
AnswerRe: ASP.Net Pin
F-ES Sitecore25-Feb-16 21:52
professionalF-ES Sitecore25-Feb-16 21:52 
AnswerRe: ASP.Net Pin
Nathan Minier26-Feb-16 1:29
professionalNathan Minier26-Feb-16 1:29 
AnswerRe: ASP.Net Pin
Manas_Kumar26-Feb-16 7:17
professionalManas_Kumar26-Feb-16 7:17 
AnswerRe: ASP.Net Pin
aarif moh shaikh26-Feb-16 21:00
professionalaarif moh shaikh26-Feb-16 21:00 
QuestionPass ViewModel to view twice Pin
Member 1204569224-Feb-16 23:29
Member 1204569224-Feb-16 23:29 
AnswerRe: Pass ViewModel to view twice Pin
Nathan Minier25-Feb-16 1:53
professionalNathan Minier25-Feb-16 1:53 
QuestionGet file size from File Upload from IE and Chrome Pin
indian14324-Feb-16 15:49
indian14324-Feb-16 15:49 
AnswerRe: Get file size from File Upload from IE and Chrome Pin
F-ES Sitecore25-Feb-16 0:46
professionalF-ES Sitecore25-Feb-16 0:46 
QuestionSet the file upload value Pin
indian14324-Feb-16 11:24
indian14324-Feb-16 11:24 
AnswerRe: Set the file upload value Pin
Richard Deeming25-Feb-16 2:21
mveRichard Deeming25-Feb-16 2:21 
Questionfile upload, restricting size and type of files Pin
indian14324-Feb-16 7:43
indian14324-Feb-16 7:43 
AnswerRe: file upload, restricting size and type of files Pin
Richard Deeming24-Feb-16 7:56
mveRichard Deeming24-Feb-16 7:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.