bmp파일 만들기

jeshin37의 이미지

c언어 완전 쌩초보인데요, bmp파일 만드는데, 난항이여서요 ㅜㅜ
(1000x1000) 이미지는 검정으로 칠하고,그 안에 (800,800) (800,900) (900,800) (900,900)의 네 꼭지점으로 이루어진 사각형 부분만 빨강으로 칠하는 코드를 작성하는 것인데요,
#include
#include
main(){

write_BMP_file();

}

write_BMP_file()
{
//bitmap file header
short int magic_number = 0x424d;
unsigned int file_size = 0x2dc6f6;
short int reserved1;
short int reserved2;
unsigned int offset = 0x36;
//bitmap info header
unsigned int info_header_file_size = 0x28;
unsigned int width = 0x3e8;
unsigned int height = 0x3e8;
short int color_frame = 0x01;
short int pixel_for_one_bit = 0x18;
unsigned int image_compression = 0x00;
unsigned int image_size = 0x2dc6c0;
unsigned int horizontal_resolution = 0x04;
unsigned int vertical_resolution = 0x04;
unsigned int color_palette = 0x00;
unsigned int number_of_important_color = 0x00;
//data
unsigned int black = 0x000000;
unsigned int red = 0x0000ff;
FILE*f;

//bitmap file header
f=fopen("mybmp.bmp","wb");
fwrite(&magic_number,2,1,f);
fwrite(&file_size,4,1,f);
fwrite(&reserved1,2,1,f);
fwrite(&reserved2,2,1,f);
fwrite(&offset,4,1,f);
//bitmap info header
fwrite(&info_header_file_size,4,1,f);
fwrite(&width,4,1,f);
fwrite(&height,4,1,f);
fwrite(&color_frame,2,1,f);
fwrite(&pixel_for_one_bit,2,1,f);
fwrite(&image_compression,4,1,f);
fwrite(&image_size,4,1,f);
fwrite(&horizontal_resolution,4,1,f);
fwrite(&vertical_resolution,4,1,f);
fwrite(&color_palette,4,1,f);
fwrite(&number_of_important_color,4,1,f);
//data
fwrite(&black,2400000,1,f);
fwrite(&black,2400,1,f);//1
fwrite(&red,300,1,f);//2
fwrite(&black,300,1,f)//3 --1,2,3을 100번 반복하려는데 어떻게 하는지 모르겠음.
fwirte(&black,3000,1,f);

fclose(f);
return 0;
}

확인해주세요~ㅠㅠ

shint의 이미지

... 참고해보세요.



줄무늬가 보입니다. 네이버에서. 비트맵 분석. 비트맵 헤더. 비트맵 저장.으로 찾으시거나.


데브피아 자료실에서 검색. 코드프로젝트에서 검색. MFC. WindowsAPI. 영상처리 책 참고해보세요.


비트맵 저장하기 연습

http://kldp.org/node/153742




[파일:7]











댓글 첨부 파일: 
첨부파일 크기
Package icon test 비트맵 저장하기 연습.zip379.01 KB

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.