Since the old files are jpg i want first read all the files pixels get the colors of them and set it back to the new files i created wich have also diffrenet format.
For example in my program original file looks like:
d:\\.........radar001.jpg
The new files should looks like d:\\........radar0000001.jpg
I just formatted the new files to be with 6 zeros iside so file radar001 will be radar000001.jpg and file radar350.jpg will be radar000350.jpg
Then i converted it to int32
Now i also created in the loop new 3200+ bitmaps empty files black bitmaps files.
Now i want to getpixel of the old files set in the new bitmaps i created the pixels and then delete the old files.
This is the code:
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Drawing;
- namespace Format_Files
- {
- class Program
- {
- static void Main(string[] args)
- {
- Bitmap[] mybitmaps;
- Image myimage;
- string c;
- string s;
- StreamWriter sw;
- string sf;
- string[] images;
- int x;
- int a;
- int b;
- sw = new StreamWriter(@"d:\stream.txt");
- sf = @"d:\RadarImagesDownloaded";
- images = Directory.GetFiles(sf, "*.jpg");
- Console.WriteLine("--- Files: ---");
- myimage = new Bitmap(512, 512);
- for (x = 0; x < images.Length; x++)
- {
- s = images[x];
- int i = s.IndexOf("radar");
- int t = s.IndexOf(".jpg");
- string d = s.Substring(i+5,s.Length-t - 1);
- int numbers = Convert.ToInt32(d);
- c = sf + @"\radar" + numbers.ToString("D6") + ".jpg";
- myimage.Save(c);
- Console.WriteLine("index: "+x+" filename:"+images[x]);
- sw.WriteLine("index: "+x+" Substring:"+ d + " Converted numbers: " + numbers + " New fileNames: " + c);
- if ((x % 500) == 0) // just to help us see the printing on the screen.. cause it is too fast..so
- // "pausing" every 500 .. (wait for user press )
- {
- Console.WriteLine(" just pausing so user can see.. : press any key to continue ...");
- Console.ReadKey(false);
- }
- }
- sw.Close();
- }
- }
- }
Now i want to make new two for's for inside for using a and b get all the pixels from the old jpg files and set the pixels into the new files wich are myimage
I know how to do it with one image you make for in for like:
for (a=0;a<newimage.width;a++)
{
for (b=0;b<newimage.height;b++)
{
Color mc = newimage.getpixel(a,b);
mynewimage.setpixel(a,b,mc);
}
}
Something like that.
Now how do i make it with array of jpg files ? According to my code.
Thanks.