비트맵 파일 픽셀 intensity를 반으로 줄이려고 하는데요...
미즈
질문 제목 : 비트맵 파일 픽셀 intensity를 반으로 줄이려고 하는데요...비트맵파일 픽셀 줄이기질문 내용 :
이코드는 그냥 이미지 사이즈를 반으로 줄이는 코드인데요..
이미지 사이즈 말고 픽셀을 반으로 줄이려면 어떻게 코드를 짜야하나요..??
코드좀 부탁드립니다ㅠㅠㅠㅠㅠㅠㅠㅠㅠ
#include stdio.h
#include stdlib.h
#include windows.h
#define r 0.5 // ratio
int main()
{
char infname[] = inputimage.bmp;
char outfname[] = outputimage1.bmp;
file *infp, *outfp;
hdc hdcold, hdcnew;
hbitmap hbmold, hbmnew;
bitmapfileheader filehead;
bitmapinfoheader infohead;
dword width,height,imgsize;
byte *pimage; infp = fopen(infname,rb);
if ( !infp ) {
printf(file open error\n);
return -1;
}
fread(&filehead,sizeof(bitmapfileheader),1,infp);
fread(&infohead,sizeof(bitmapinfoheader),1,infp);
width = infohead.biwidth;
height = infohead.biheight;
imgsize = width * height * (infohead.bibitcount/8);
pimage = (byte*)malloc(imgsize);
fread(pimage,1,imgsize,infp);
fclose(infp);
hbmold = createdibitmap(getdc(null),&infohead,cbm_init,pimage,(bitmapinfo*)&infohead,dib_rgb_colors);
hdcold = createcompatibledc(getdc(null));
selectobject(hdcold, hbmold);
// create new image
hdcnew = createcompatibledc(getdc(null));
hbmnew = createcompatiblebitmap(getdc(null),width*r,height*r);
selectobject(hdcnew, hbmnew);
setstretchbltmode(hdcnew, halftone);
stretchblt(hdcnew,0,0,width*r,height*r,hdcold,0,0,width,height,srccopy);
infohead.biwidth = width * r;
infohead.biheight = height * r;
infohead.bisizeimage = imgsize * (r*r);
getdibits(hdcnew,hbmnew, 0, infohead.biheight, pimage,
(bitmapinfo*)&infohead,dib_rgb_colors);
// write
filehead.bfsize = sizeof(bitmapinfoheader) + infohead.bisizeimage;
outfp = fopen(outfname,wb);
if ( !outfp ) {
printf(file open error\n);
return -1;
}
fwrite(&filehead, sizeof(bitmapfileheader),1,outfp);
fwrite(&infohead, sizeof(bitmapinfoheader),1,outfp);
fwrite(pimage, 1, infohead.bisizeimage, outfp);
fclose(outfp);
free(pimage);
deleteobject(hbmold);
deleteobject(hbmnew);
deletedc(hdcold);
deletedc(hdcnew);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2692144 | C언어와 리눅스에 대한 질문입니다. | 싴흐한세여니 | 2025-04-20 |
2692114 | 컨텍스트 스위칭하는데 걸리는 시간 측정.. | YourWay | 2025-04-19 |
2692086 | 간접참조 연산자, 증감연산자 질문이용! (2) | 블랙캣 | 2025-04-19 |
2692056 | 주석좀 달아주세요. 몇개적엇는데 몇개만달아주세요. (2) | DevilsTears | 2025-04-19 |
2691978 | 진수 쉽게 이해하는법... (3) | 지지않는 | 2025-04-18 |
2691949 | getchar() 한 문자를 입력받는 함수 질문 | 채꽃 | 2025-04-18 |
2691919 | 배열 정렬 및 합치기 질문입니다. | 사과 | 2025-04-18 |
2691845 | c언어왕초보 질문이 있습니다........ | 루나 | 2025-04-17 |
2691815 | void add(int num); 함수... (4) | 살랑살랑 | 2025-04-17 |
2691756 | 명령 프롬프트 스크롤바가 없어요 | 두메꽃 | 2025-04-16 |
2691725 | 자료구조에 관련해서 질문이 있어 글을 올립니다. | 누리알찬 | 2025-04-16 |
2691697 | if 문에서 구조체 배열에 저장되있던 문자열 검사하는 법 ? (2) | 민트맛사탕 | 2025-04-16 |
2691678 | C언어 함수 질문이요~!!! | 연보라 | 2025-04-15 |
2691650 | 반복문 | 돋가이 | 2025-04-15 |
2691618 | 링크드리스트 개념 질문이예요 (3) | 맨마루 | 2025-04-15 |
2691592 | 동적할당 이용 배열선언 질문입니다.ㅠㅠ (3) | 허리달 | 2025-04-15 |
2691542 | /=의 용도를 알려주세요 ㅠㅠ! (2) | 아라 | 2025-04-14 |
2691510 | sizeof 연산자 질문입니다 (2) | 종달 | 2025-04-14 |
2691483 | 파일 오픈시 에러 질문드립니다. (2) | 호습다 | 2025-04-14 |
2691450 | [visual c++ 툴]기초 질문 (3) | 해긴 | 2025-04-13 |