Click here to Skip to main content
15,887,427 members
Home / Discussions / C#
   

C#

 
AnswerRe: Invoke/Thread Pin
Mohammad Dayyan23-Sep-08 18:51
Mohammad Dayyan23-Sep-08 18:51 
GeneralRe: Invoke/Thread Pin
myNameIsRon23-Sep-08 19:30
myNameIsRon23-Sep-08 19:30 
GeneralRe: Invoke/Thread Pin
Mohammad Dayyan24-Sep-08 3:45
Mohammad Dayyan24-Sep-08 3:45 
AnswerRe: Invoke/Thread Pin
Mark Churchill23-Sep-08 22:59
Mark Churchill23-Sep-08 22:59 
GeneralRe: Invoke/Thread Pin
myNameIsRon24-Sep-08 4:30
myNameIsRon24-Sep-08 4:30 
GeneralRe: Invoke/Thread Pin
Mark Churchill24-Sep-08 18:56
Mark Churchill24-Sep-08 18:56 
GeneralRe: Invoke/Thread Pin
myNameIsRon24-Sep-08 19:47
myNameIsRon24-Sep-08 19:47 
QuestionOut of memory error Pin
Xmen Real 23-Sep-08 17:14
professional Xmen Real 23-Sep-08 17:14 
hi guys,
i have developed an application that will convert every image file in selected folder to .png and scale images to some specified sizes with checking which one is best. Those sizes are 64 128 256 512 1024 2048. The app checks which is nearest size to scale. For instance, if image dimension is (65 x 125) then it will scale it to 64 x 128 because 65 is nearest to 64 than 128 and 125 is nearest to 128 than 64 and so on...so to this i have coded the app like this :

private void button3_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                Xal.Clear(); // ArrayList               
                getDirs(fbd.SelectedPath); // To Fill AL
                string[] tmp_filePaths = (string[])Xal.ToArray(typeof(string));
                for (int a = 0; a < tmp_filePaths.Length; a++)
                {
                    if (!tmp_filePaths[a].EndsWith(".txt"))
                    {
                        Image tmp_image = Image.FromFile(tmp_filePaths[a]); //<< Error Line (out of memory)
                        int newwidth = roundToNearestPixel(tmp_image.Width);
                        int newheight = roundToNearestPixel(tmp_image.Height);
                        Bitmap tmp_bmp = new Bitmap(newwidth, newheight);
                        Graphics tmp_gra = Graphics.FromImage(tmp_bmp);
                        tmp_gra.DrawImage(tmp_image, 0, 0, newwidth, newheight);
                        tmp_bmp.Save(@"D:\texts\" + Path.GetFileNameWithoutExtension(tmp_filePaths[a]) + ".png", System.Drawing.Imaging.ImageFormat.Png);
                        tmp_gra.Dispose();
                    }
                }
            }            
        }

        short[] dimensions = new short[] { 64, 128, 256, 512, 1024, 2048, 4096 };
        int roundToNearestPixel(int value)
        {
            int result;
            if (value <= 64)
            {
                result = 64;
                return result;
            }
            int pointer = 0;

            for (int a = 0; a < dimensions.Length; a++)
            {
                if (dimensions[a] >= value)
                {
                    pointer = a;
                    break;
                }
            }
            int shortdistance = value - dimensions[pointer - 1];
            int largedistance = dimensions[pointer] - value;
            if (shortdistance < largedistance)
                result = dimensions[pointer - 1];
            else
                result = dimensions[pointer];
            return result;
        }


now its doing what i needed but it gives an error as well that is out of memory after every 174 images, i have commented that line. So can anybody tell me how to solve this ?

thanks

TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can

AnswerRe: Out of memory error Pin
N a v a n e e t h23-Sep-08 17:26
N a v a n e e t h23-Sep-08 17:26 
GeneralRe: Out of memory error Pin
Xmen Real 23-Sep-08 17:36
professional Xmen Real 23-Sep-08 17:36 
GeneralRe: Out of memory error Pin
N a v a n e e t h23-Sep-08 17:53
N a v a n e e t h23-Sep-08 17:53 
GeneralRe: Out of memory error Pin
Xmen Real 23-Sep-08 18:12
professional Xmen Real 23-Sep-08 18:12 
GeneralRe: Out of memory error Pin
N a v a n e e t h23-Sep-08 18:14
N a v a n e e t h23-Sep-08 18:14 
GeneralRe: Out of memory error Pin
Xmen Real 23-Sep-08 19:40
professional Xmen Real 23-Sep-08 19:40 
GeneralRe: Out of memory error Pin
leppie23-Sep-08 21:31
leppie23-Sep-08 21:31 
QuestionNeed to clarify Pin
Member 409922223-Sep-08 15:32
Member 409922223-Sep-08 15:32 
AnswerRe: Need to clarify Pin
Mark Salsbery23-Sep-08 16:11
Mark Salsbery23-Sep-08 16:11 
GeneralRe: Need to clarify Pin
Member 409922223-Sep-08 16:58
Member 409922223-Sep-08 16:58 
GeneralRe: Need to clarify Pin
Mark Salsbery23-Sep-08 18:43
Mark Salsbery23-Sep-08 18:43 
AnswerRe: Need to clarify Pin
N a v a n e e t h23-Sep-08 17:30
N a v a n e e t h23-Sep-08 17:30 
AnswerRe: Need to clarify Pin
Steve Echols23-Sep-08 17:42
Steve Echols23-Sep-08 17:42 
QuestionXML Pin
CodingYoshi23-Sep-08 15:27
CodingYoshi23-Sep-08 15:27 
AnswerRe: XML Pin
N a v a n e e t h23-Sep-08 17:35
N a v a n e e t h23-Sep-08 17:35 
GeneralRe: XML Pin
CodingYoshi24-Sep-08 3:58
CodingYoshi24-Sep-08 3:58 
GeneralRe: XML Pin
N a v a n e e t h24-Sep-08 6:55
N a v a n e e t h24-Sep-08 6:55 

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.