Path: chuka.playstation.co.uk!news From: Craig Graham Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: TIM conversion Date: Thu, 07 May 1998 15:35:51 +0100 Organization: Intelligent Research Lines: 233 Message-ID: <3551C6C7.6D8BF731@hinge.mistral.co.uk> References: <3551B600.C6B737B7@clara.net> NNTP-Posting-Host: 194.131.235.3 Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------6ACFE1930C14622AF96B46E3" X-Mailer: Mozilla 4.03 [en] (Win95; I) This is a multi-part message in MIME format. --------------6ACFE1930C14622AF96B46E3 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ian Thompson wrote: > Hi, > > Has anybody written anything for coverting BMP to TIM format. I wish to incoperate TIM convertion into a util I am writing for the PC. (Not using > TIMUTIL.) > > Any help will be appreciated. > > Ian Thompson Almost...this'll load BMP's or TIM's and save BMP's. Just add a save TIM method - then mail me it back again ;) Craig. --------------6ACFE1930C14622AF96B46E3 Content-Type: text/plain; charset=us-ascii; name="ImageFile.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ImageFile.cpp" #include "stdafx.h" #include "ImageFile.h" CImageFile::CImageFile() { image=NULL; } CImageFile::~CImageFile() { if(image) free(image); } BOOL CImageFile::LoadBMP(char *fn) { FILE *f; BMP_Header hd; f=fopen(fn,"rb"); if(f) { fseek(f,2,0); fread(&hd,sizeof(BMP_Header),1,f); w=hd.w; h=hd.h; bpp=hd.bpp; fread(palette,4,1<>5)&31)<<8)|(((X>>10)&31))) BOOL CImageFile::LoadTIM(char *fn) { FILE *f; TIM_Header hd; TIM_ImageHeader i; TIM_ClutHeader c; unsigned int mode; int bnum,ln,bn; unsigned short t,n; unsigned char tmp,r,g,b; int lineT,lineB; int bpl; f=fopen(fn,"rb"); if(f) { fread(&hd,sizeof(TIM_Header),1,f); mode=hd.mode_flag&TIM_FLAG_MODE_MASK; switch(mode) { case TIM_FLAG_4BIT: bpp=4; break; case TIM_FLAG_8BIT: bpp=8; break; } if(hd.mode_flag&TIM_FLAG_CLUT) { fread(&c,sizeof(TIM_ClutHeader),1,f); bnum=c.bytes-sizeof(TIM_ClutHeader); n=0; while(bnum) { fread(&t,2,1,f); r=(t&31)<<3; g=((t>>5)&31)<<3; b=((t>>10)&31)<<3; palette[n++]=(r<<16)+(g<<8)+b; bnum-=2; } } fread(&i,sizeof(TIM_ImageHeader),1,f); bnum=i.bytes-sizeof(TIM_ImageHeader); if(bpp==8) w=i.w*2; if(bpp==4) w=i.w*4; h=i.h; if(image) free(image); image=(unsigned char*)malloc(bnum); fread(image,1,bnum,f); bpl=w*bpp/8; // Invert lines (BMP stores bitmaps upside down) for(ln=0; ln