SMALL
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
	internal class Program
	{
		//바이너리파일 공부하기
		static void Main(string[] args)
    {
      /// 1단계 : 파일 열기
      string fullName = "C:\\Users\\dawoon101\\Desktop\\!자동저장캡처\\2022-04-11 10 13 47.png";
      BinaryReader br
          = new BinaryReader(File.Open(fullName, FileMode.Open));
      // 2단계 : 파일 처리하기... 내맘대로.. 
      // 파일 --> 메모리(배열)
      int ROW = 512, COL = 512;
      byte[,] image = new byte[ROW, COL];
      for (int i = 0; i < ROW; i++)
      {
        for (int k = 0; k < COL; k++)
        {
          image[i, k] = br.ReadByte();
        }
      }

      printImage(image);

      // 3단계 : 파일 닫기
      br.Close();
      Console.ReadKey();
    }

		private static void printImage(byte[,] img)
    {
      Console.WriteLine();
      for (int i = 0; i < 10; i++)
      {
        for (int k = 0; k < 10; k++)
        {
          Console.Write("{0:d3} ", img[i, k]);
        }
        Console.WriteLine();
      }
    }
  }
}
LIST

'일반' 카테고리의 다른 글

Html 기술  (0) 2022.05.16
Html 연습하기  (0) 2022.05.16
베어테일분석하기  (0) 2022.04.21
sql  (0) 2022.04.19
datagridview pageup pagedown 10칸씩 움직이기  (0) 2022.04.18

+ Recent posts