Click here to Skip to main content
15,888,351 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Custom Control Visual Basic .Net Pin
Dave Kreskowiak8-Feb-14 2:54
mveDave Kreskowiak8-Feb-14 2:54 
GeneralRe: Custom Control Visual Basic .Net Pin
JM768-Feb-14 3:04
JM768-Feb-14 3:04 
QuestionToolstrip Pin
KirtiZare7-Feb-14 22:42
KirtiZare7-Feb-14 22:42 
AnswerRe: Toolstrip Pin
Dave Kreskowiak8-Feb-14 2:51
mveDave Kreskowiak8-Feb-14 2:51 
Questionnot able to save image which is already saved with same name and to the same location Pin
ven7537-Feb-14 18:05
ven7537-Feb-14 18:05 
AnswerRe: not able to save image which is already saved with same name and to the same location Pin
TnTinMn7-Feb-14 18:37
TnTinMn7-Feb-14 18:37 
GeneralRe: not able to save image which is already saved with same name and to the same location Pin
ven7537-Feb-14 23:22
ven7537-Feb-14 23:22 
GeneralRe: not able to save image which is already saved with same name and to the same location Pin
TnTinMn8-Feb-14 8:43
TnTinMn8-Feb-14 8:43 
I learned something new; the BitMap(Image img) constructor does all of that painting of the source Image to a new BitMap for you. Cool! Big Grin | :-D Big Grin | :-D

Now for your issue. Give this a try. I rewrote the logic to get the JPEG encoder assuming that is the one you wanted. If not, it is easy to change and understand now. There should really be some handling in there in the unlikely event that the encoder does not exist. But you can add that easily enough.

if (System.IO.File.Exists(serpath))
{

    System.Drawing.Image myimage1 = System.Drawing.Image.FromFile(serpath);

    int thumb_width = 400, thumb_height = 100;
    using (System.Drawing.Bitmap thumb_bitmap = new System.Drawing.Bitmap(thumb_width, thumb_height))
    {
        using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumb_bitmap))
        {
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            g.Clear(Color.White);
            g.DrawImage(myimage1, 0, 0, thumb_width, thumb_height);
        }
        myimage1.Dispose();
        System.Drawing.Imaging.ImageCodecInfo jpeg = default(System.Drawing.Imaging.ImageCodecInfo);
        jpeg = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders().
               Where((System.Drawing.Imaging.ImageCodecInfo enc) => 
                   enc.FormatID == System.Drawing.Imaging.ImageFormat.Jpeg.Guid)
                   .FirstOrDefault();


        System.Drawing.Imaging.EncoderParameters Params = new System.Drawing.Imaging.EncoderParameters(1);
        Params.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);

        thumb_bitmap.Save(serpath, jpeg, Params);

    }
    
}
else
{
    signatureImage.Save(serpath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}

GeneralRe: not able to save image which is already saved with same name and to the same location Pin
ven7539-Feb-14 2:13
ven7539-Feb-14 2:13 
AnswerRe: not able to save image which is already saved with same name and to the same location Pin
PKJain7512-Feb-14 23:51
professionalPKJain7512-Feb-14 23:51 
Questionpopulating data from datagridview into textboxes Pin
Member 105062157-Feb-14 1:10
Member 105062157-Feb-14 1:10 
QuestionRe: populating data from datagridview into textboxes Pin
Eddy Vluggen7-Feb-14 8:55
professionalEddy Vluggen7-Feb-14 8:55 
QuestionError in conversion of application Pin
Ashish Sharma6-Feb-14 18:18
Ashish Sharma6-Feb-14 18:18 
AnswerRe: Error in conversion of application Pin
thatraja6-Feb-14 20:24
professionalthatraja6-Feb-14 20:24 
Questionnot able to Deserialize json signature lines Pin
ven7534-Feb-14 18:36
ven7534-Feb-14 18:36 
AnswerRe: not able to Deserialize json signature lines Pin
Richard Deeming5-Feb-14 2:57
mveRichard Deeming5-Feb-14 2:57 
GeneralRe: not able to Deserialize json signature lines Pin
ven7535-Feb-14 5:17
ven7535-Feb-14 5:17 
GeneralRe: not able to Deserialize json signature lines Pin
Richard Deeming5-Feb-14 5:35
mveRichard Deeming5-Feb-14 5:35 
GeneralRe: not able to Deserialize json signature lines Pin
ven7535-Feb-14 6:11
ven7535-Feb-14 6:11 
GeneralRe: not able to Deserialize json signature lines Pin
Richard Deeming5-Feb-14 6:50
mveRichard Deeming5-Feb-14 6:50 
GeneralRe: not able to Deserialize json signature lines Pin
ven7535-Feb-14 7:18
ven7535-Feb-14 7:18 
GeneralRe: not able to Deserialize json signature lines Pin
Richard Deeming5-Feb-14 8:01
mveRichard Deeming5-Feb-14 8:01 
GeneralRe: not able to Deserialize json signature lines Pin
ven7535-Feb-14 16:09
ven7535-Feb-14 16:09 
GeneralRe: not able to Deserialize json signature lines Pin
Richard Deeming6-Feb-14 1:37
mveRichard Deeming6-Feb-14 1:37 
GeneralRe: not able to Deserialize json signature lines Pin
ven7536-Feb-14 6:54
ven7536-Feb-14 6:54 

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.