Click here to Skip to main content
15,889,335 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Opening word/pdf document in another window Pin
indian1431-Mar-16 6:06
indian1431-Mar-16 6:06 
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 
I think I interpreted the Graphics Object wrong.
It's just a processor, that converts, the Bitmap is the object or image.
I don't have the whole thing working yet, but I think it will, but I do see bytes in the output.
And I think I used using correctly on the Graphics processor, not sure about disposing of some of the other stuff.

It's been years since I wrote an image resizer, but I did it in VB last.
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();
    MemoryStream ms_out = new MemoryStream();
    MemoryStream ms_in = new MemoryStream(pBytes);
    Image requestObj = Image.FromStream(ms_in);

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

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

    // Create the new response Image, that will overlay the Bitmap
    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 xLeft = (cWidth - t_Width) / 2;
        int xTop = (cHeight - t_Height) / 2;

        // Create the new Image Object
        graphicObj.DrawImage(bitmapObj, xLeft, xTop, t_Width, t_Height);

        // Create a new MemoryStream to Save the Image to<br />
        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;
}   

General[Now it works], but needs advice on disposing Pin
jkirkerx29-Feb-16 12:51
professionaljkirkerx29-Feb-16 12:51 
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 

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.