#include "basetype.h"#include "pixelformat.h"#include "vfile.h"Go to the source code of this file.
|
|
|
|
|
|
|
|
|
|
|
if Bitmap is a lock for read, functions that modify it return failure if Bitmap is a lock for write, functions that modify it attempt to modify the owner of the lock warning : if you lock multiple mips for write, and then modify one of the mips (such as via SetPalette) it may affect the owner and all sibling mips! doing different SetPalettes with different palettes on different locked mips has undefined behavior!
Definition at line 217 of file bitmap.h.
00218 {
00219 GE_BITMAP_STREAMING_ERROR=0,
00220 GE_BITMAP_STREAMING_NOT,
00221 GE_BITMAP_STREAMING_STARTED,
00222 GE_BITMAP_STREAMING_IDLE,
00223 GE_BITMAP_STREAMING_CHANGED,
00224 GE_BITMAP_STREAMING_DATADONE,
00225 GE_BITMAP_STREAMING_DONE,
00226 } geBitmap_StreamingStatus;
|
|
||||||||||||||||||||||||||||||||||||
|
Definition at line 2902 of file bitmap.c. References geBitmap_BlitMipRect(), geBitmap_IsValid(), geBoolean, GENESISAPI, GENESISCC, SizeX, and SizeY. Referenced by geFont_DrawTextToBitmap().
02905 {
02906 assert( geBitmap_IsValid(Src) );
02907 assert( geBitmap_IsValid(Dst) );
02908 return geBitmap_BlitMipRect(Src,0,SrcPositionX,SrcPositionY,
02909 Dst,0,DstPositionX,DstPositionY,
02910 SizeX,SizeY);
02911 }
|
|
||||||||||||
|
Definition at line 2921 of file bitmap.c. References geBitmap_BlitMipRect(), geBitmap_IsValid(), geBoolean, GENESISAPI, GENESISCC, geBitmap::Info, SHIFT_R_ROUNDUP, and geBitmap_Info::Width.
02922 {
02923 int Width,Mip;
02924 assert( geBitmap_IsValid(Src) );
02925 assert( geBitmap_IsValid(Dst) );
02926 assert( Src != Dst );
02927 for(Mip=0; (Width = SHIFT_R_ROUNDUP(Src->Info.Width,Mip)) > Dst->Info.Width ; Mip++) ;
02928 return geBitmap_BlitMipRect(Src,Mip,0,0,Dst,0,0,0,-1,-1);
02929 }
|
|
||||||||||||
|
Definition at line 2913 of file bitmap.c. References geBitmap_BlitMipRect(), geBitmap_IsValid(), geBoolean, GENESISAPI, and GENESISCC. Referenced by BumpMap_Create(), geBitmap_BlitData_Sub(), geBitmapUtil_SetAlphaFromBrightness(), geEngine_InitFonts(), and Plasma_Create().
02914 {
02915 assert( geBitmap_IsValid(Src) );
02916 assert( geBitmap_IsValid(Dst) );
02917 assert( Src != Dst );
02918 return geBitmap_BlitMipRect(Src,0,0,0,Dst,0,0,0,-1,-1);
02919 }
|
|
||||||||||||||||||||
|
Definition at line 2931 of file bitmap.c. References geBitmap_BlitMipRect(), geBitmap_IsValid(), geBoolean, GENESISAPI, and GENESISCC. Referenced by geBitmap_CreateLockFromMip().
02932 {
02933 assert( geBitmap_IsValid(Src) );
02934 assert( geBitmap_IsValid(Dst) );
02935 return geBitmap_BlitMipRect(Src,SrcMip,0,0,Dst,DstMip,0,0,-1,-1);
02936 }
|
|
|
Definition at line 2681 of file bitmap.c. References geBitmap::Data, geBitmap::DataOwner, geBitmap::Driver, GE_FALSE, GE_TRUE, geBitmap_AttachToDriver(), geBitmap_DetachDriver(), geBitmap_IsValid(), geBoolean, GENESISAPI, GENESISCC, geRam_Free, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, geBitmap_Info::MaximumMip, geBitmap_Info::MinimumMip, NULL, and geBitmap::SeekMipCount. Referenced by BumpMap_Create(), ElectricFx_InitBitmap(), Fire_Create(), geBitmap_SetFormat(), Particles_InitBitmap(), Plasma_Create(), Smoke_InitBitmap(), and Water_Create().
02682 {
02683 int mip;
02684 DRV_Driver * Driver;
02685
02686 // WARNING ! This destroys any mips!
02687
02688 assert( geBitmap_IsValid(Bmp) );
02689
02690 if ( Bmp->LockOwner || Bmp->LockCount || Bmp->DataOwner )
02691 return GE_FALSE;
02692
02693 if ( Bmp->SeekMipCount == 0 && Bmp->Info.MaximumMip == 0 )
02694 return GE_TRUE;
02695
02696 Driver = Bmp->Driver;
02697 if ( Driver )
02698 {
02699 if ( ! geBitmap_DetachDriver(Bmp,GE_TRUE) )
02700 return GE_FALSE;
02701 }
02702 assert(Bmp->Driver == NULL);
02703
02704 mip = Bmp->Info.MinimumMip;
02705 if ( mip == 0 )
02706 mip++;
02707
02708 Bmp->SeekMipCount = mip;
02709
02710 for( ; mip <= Bmp->Info.MaximumMip ; mip++)
02711 {
02712 if ( Bmp->Data[mip] )
02713 {
02714 geRam_Free( Bmp->Data[mip] );
02715 Bmp->Data[mip] = NULL;
02716 }
02717 }
02718
02719 Bmp->Info.MaximumMip = Bmp->Info.MinimumMip;
02720
02721 if ( Driver )
02722 {
02723 if ( ! geBitmap_AttachToDriver(Bmp,Driver,0) )
02724 return GE_FALSE;
02725 }
02726
02727 return GE_TRUE;
02728 }
|
|
||||||||||||||||||||
|
|
Definition at line 3747 of file bitmap.c. References geBitmap::Alpha, geBitmap::Data, geBitmap_Info::Format, GE_FALSE, GE_PIXELFORMAT_WAVELET, GE_TRUE, GE_VFILE_OPEN_READONLY, GE_VFILE_SEEKCUR, geBitmap_AllocSystemMip(), geBitmap_Create_Base(), geBitmap_Destroy(), geBitmap_IsTGA(), geBitmap_MipBytes(), geBitmap_Palette_CreateFromFile(), geBitmap_ReadFromBMP(), geBitmap_ReadFromTGA(), geBitmap_ReadInfo(), GEBM_TAG, GEBM_VERSION, geBmTag_t, geErrorLog_AddString, GENESISAPI, GENESISCC, geVFile_Close(), geVFile_OpenNewSystem(), geVFile_Read(), geVFile_Seek(), geBitmap::Info, geBitmap_Info::MaximumMip, geBitmap_Info::MinimumMip, MIP_FLAG_COMPRESSED, MIP_FLAG_PAETH_FILTERED, MIP_MASK, geBitmap::Modified, NULL, geBitmap_Info::Palette, geBitmap_Info::Stride, uint8, VERSION_MAJOR, and geBitmap_Info::Width. Referenced by geBitmap_CreateFromFileName(), geBitmapUtil_CreateFromFileName(), geBody_CreateFromFile(), geEngine_InitFonts(), GetABitmap(), and Text_Create().
03748 {
03749 geBitmap * Bmp;
03750 geBmTag_t Tag;
03751
03752 assert(F);
03753
03754 if ( ! geVFile_Read(F, &Tag, sizeof(Tag)) )
03755 return NULL;
03756
03757 Bmp = geBitmap_Create_Base();
03758 if ( ! Bmp )
03759 return NULL;
03760
03761 if ( Tag == GEBM_TAG )
03762 {
03763 uint8 flags;
03764 uint8 Version;
03765 int mip;
03766
03767 // see WriteToFile for comments on the file format
03768
03769 if ( ! geVFile_Read(F, &Version, sizeof(Version)) )
03770 goto fail;
03771
03772 if ( VERSION_MAJOR(Version) != VERSION_MAJOR(GEBM_VERSION) )
03773 {
03774 geErrorLog_AddString(-1,"CreateFromFile : incompatible GeBm version", NULL);
03775 goto fail;
03776 }
03777
03778 if ( ! geBitmap_ReadInfo(Bmp,F) )
03779 goto fail;
03780
03781 if ( Bmp->Info.Palette )
03782 {
03783 Bmp->Info.Palette = NULL;
03784 if ( ! ( Bmp->Info.Palette = geBitmap_Palette_CreateFromFile(F)) )
03785 goto fail;
03786 }
03787
03788 if ( Bmp->Info.Format == GE_PIXELFORMAT_WAVELET )
03789 {
03790 geErrorLog_AddString(-1,"Genesis3D 1.0 does not support Wavelet Images",NULL);
03791 }
03792 else
03793 {
03794 for(;;)
03795 {
03796 if ( ! geVFile_Read(F, &flags, sizeof(flags)) )
03797 goto fail;
03798
03799 mip = flags & MIP_MASK;
03800
03801 if ( mip > Bmp->Info.MaximumMip )
03802 break;
03803
03804 assert(mip >= Bmp->Info.MinimumMip );
03805 assert( Bmp->Info.Stride == Bmp->Info.Width );
03806
03807 if ( ! geBitmap_AllocSystemMip(Bmp,mip) )
03808 goto fail;
03809
03810 if ( flags & MIP_FLAG_COMPRESSED )
03811 {
03812 #ifdef DO_LZ
03813 geVFile * LzF;
03814
03815 LzF = geVFile_OpenNewSystem(F,GE_VFILE_TYPE_LZ,NULL,NULL,GE_VFILE_OPEN_READONLY);
03816 if ( ! LzF )
03817 {
03818 geErrorLog_AddString(-1,"Bitmap_CreateFromFile : LZ File Open failed",NULL);
03819 return GE_FALSE;
03820 }
03821
03822 if ( ! geVFile_Read(LzF, Bmp->Data[mip], geBitmap_MipBytes(Bmp,mip) ) )
03823 {
03824 geVFile_Close(LzF);
03825 geErrorLog_AddString(-1,"Bitmap_CreateFromFile : LZ File Read failed",NULL);
03826 return GE_FALSE;
03827 }
03828
03829 if ( ! geVFile_Close(LzF) )
03830 {
03831 geErrorLog_AddString(-1,"Bitmap_CreateFromFile : LZ File Close failed",NULL);
03832 return GE_FALSE;
03833 }
03834 #endif
03835 }
03836 else
03837 {
03838 if ( ! geVFile_Read(F, Bmp->Data[mip], geBitmap_MipBytes(Bmp,mip) ) )
03839 goto fail;
03840 }
03841
03842 if ( flags & MIP_FLAG_PAETH_FILTERED )
03843 {
03844 geErrorLog_AddString(-1,"Bitmap_CreateFromFile : Paeth Filter not supported in this version!",NULL);
03845 return GE_FALSE;
03846 }
03847
03848 Bmp->Modified[mip] = GE_TRUE;
03849 }
03850 }
03851
03852 if( Bmp->Alpha )
03853 {
03854 if ( ! (Bmp->Alpha = geBitmap_CreateFromFile(F)) )
03855 goto fail;
03856 }
03857 } // end geBitmap reader
03858 else
03859 {
03860 if ( ! geVFile_Seek(F, - (int)sizeof(Tag), GE_VFILE_SEEKCUR) )
03861 goto fail;
03862
03863 if ( (Tag&0xFFFF) == 0x4D42 ) // 'BM'
03864 {
03865
03866 if ( ! geBitmap_ReadFromBMP(Bmp,F) )
03867 goto fail;
03868 }
03869 else
03870 {
03871
03872 // change QuestOfDreams
03873 if (geBitmap_IsTGA(F))
03874 {
03875 if( ! geBitmap_ReadFromTGA(Bmp, F))
03876 goto fail;
03877 }
03878 else
03879 // geErrorLog_AddString(-1,"CreateFromFile : unknown format", NULL);
03880 goto fail;
03881 // end change QuestOfDreams
03882 }
03883 }
03884
03885 return Bmp;
03886
03887 fail:
03888 assert(Bmp);
03889
03890 geBitmap_Destroy(&Bmp);
03891 return NULL;
03892 }
|
|
||||||||||||
|
Definition at line 3682 of file bitmap.c. References GE_VFILE_OPEN_READONLY, GE_VFILE_TYPE_DOS, geBitmap_CreateFromFile(), GENESISAPI, GENESISCC, geVFile_Close(), geVFile_Open(), geVFile_OpenNewSystem(), and NULL. Referenced by Client_CreateStatusBar(), GameMgr_SetTextureIndex(), GMenu_Create(), PathPoint_SetTexture(), and SetupConsole().
03683 {
03684 geVFile * File;
03685 geBitmap * Bitmap;
03686
03687
03688 if ( BaseFS )
03689 {
03690 File = geVFile_Open((geVFile *)BaseFS, Name, GE_VFILE_OPEN_READONLY);
03691 }
03692 else
03693 {
03694 File = geVFile_OpenNewSystem(NULL,GE_VFILE_TYPE_DOS,Name,NULL,GE_VFILE_OPEN_READONLY);
03695 }
03696 if ( ! File )
03697 return NULL;
03698
03699 Bitmap = geBitmap_CreateFromFile(File);
03700 geVFile_Close(File);
03701
03702 return Bitmap;
03703 }
|
|
|
Definition at line 204 of file bitmap.c. References geBitmap_Info::Format, GE_PIXELFORMAT_WAVELET, geBitmap_Create_Base(), geBitmap_Info_IsValid(), geBitmap_Palette_CreateRef(), geErrorLog_AddString, GENESISAPI, GENESISCC, geBitmap::Info, NULL, geBitmap_Info::Palette, geBitmap_Info::Stride, and geBitmap_Info::Width. Referenced by geBitmapUtil_SetAlphaFromBrightness().
00205 {
00206 geBitmap * Bmp;
00207
00208 assert(pInfo);
00209 assert(geBitmap_Info_IsValid(pInfo));
00210
00211 Bmp = geBitmap_Create_Base();
00212 if ( ! Bmp )
00213 return NULL;
00214
00215 Bmp->Info = *pInfo;
00216
00217 if ( Bmp->Info.Stride < Bmp->Info.Width )
00218 Bmp->Info.Stride = Bmp->Info.Width;
00219
00220 if ( Bmp->Info.Palette )
00221 geBitmap_Palette_CreateRef(Bmp->Info.Palette);
00222
00223 if ( Bmp->Info.Format == GE_PIXELFORMAT_WAVELET )
00224 {
00225 geErrorLog_AddString(-1,"Genesis3D 1.0 does not support Wavelet Images",NULL);
00226 return NULL;
00227 }
00228
00229 return Bmp;
00230 }
|
|
|
|
|
Definition at line 3599 of file bitmap.c. References geBitmap::Alpha, GENESISAPI, GENESISCC, and NULL.
|
|
||||||||||||||||||||
|
Definition at line 5577 of file bitmap.c. References A, B, geBitmap_Info::ColorKey, geBitmap::Data, gePixelFormat_Operations::DecomposePixel, geBitmap::DriverDataChanged, geBitmap::DriverHandle, geBitmap_Info::Format, G, GE_FALSE, GE_TRUE, geBitmap_Update_DriverToSystem(), geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, gePixelFormat, gePixelFormat_BytesPerPel(), gePixelFormat_ColorGetter, gePixelFormat_Decomposer, gePixelFormat_GetOperations(), gePixelFormat_HasPalette(), gePixelFormat_IsRaw(), gePixelFormat_PixelGetter, gePixelFormat_Operations::GetColor, gePixelFormat_Operations::GetPixel, geBitmap_Info::HasColorKey, geBitmap_Info::Height, geBitmap::Info, NULL, R, geBitmap_Info::Stride, uint32, uint8, geBitmap_Info::Width, and y.
05578 {
05579 {
05580 int bpp,x,y,w,h,xtra,dock;
05581 gePixelFormat Format;
05582 uint8 * ptr;
05583 uint32 R,G,B,A,Rt,Gt,Bt,cnt,ck;
05584
05585 //{} Rt == Rtotal , probably won't overflow; we can handle a 4096x4095 solid-white image
05586
05587 if ( Bmp->DriverHandle && Bmp->DriverDataChanged )
05588 {
05589 // must use the driver bits
05590 if ( ! geBitmap_Update_DriverToSystem((geBitmap *)Bmp) )
05591 {
05592 geErrorLog_AddString(-1,"Bitmap_AverageColor : DriverToSystem failed!",NULL);
05593 return GE_FALSE;
05594 }
05595 }
05596
05597 Format = Bmp->Info.Format;
05598 bpp = gePixelFormat_BytesPerPel(Format);
05599 ptr = Bmp->Data[0];
05600
05601 if ( ! ptr || bpp < 1 )
05602 {
05603 geErrorLog_AddString(-1,"Bitmap_AverageColor : no data!",NULL);
05604 return GE_FALSE;
05605 }
05606
05607 w = Bmp->Info.Width;
05608 h = Bmp->Info.Height;
05609 xtra = (Bmp->Info.Stride - w)*bpp;
05610 ck = Bmp->Info.ColorKey;
05611 dock = Bmp->Info.HasColorKey;
05612
05613 Rt = Gt = Bt = cnt = 0;
05614
05615 if ( gePixelFormat_HasPalette(Format) )
05616 {
05617 // <> Blech!
05618 geErrorLog_AddString(-1,"Bitmap_AverageColor : doesn't support palettized yet!",NULL);
05619 #pragma message("Bitmap_AverageColor : doesn't support palettized yet!")
05620 return GE_FALSE;
05621 }
05622 else
05623 {
05624 const gePixelFormat_Operations * ops;
05625 gePixelFormat_ColorGetter GetColor;
05626 gePixelFormat_PixelGetter GetPixel;
05627 gePixelFormat_Decomposer Decomposer;
05628
05629 assert( gePixelFormat_IsRaw(Format) );
05630
05631 ops = gePixelFormat_GetOperations(Format);
05632 GetColor = ops->GetColor;
05633 GetPixel = ops->GetPixel;
05634 Decomposer = ops->DecomposePixel;
05635
05636 if ( dock )
05637 {
05638 for(y=h;y--;)
05639 {
05640 for(x=w;x--;)
05641 {
05642 uint32 Pixel;
05643 Pixel = GetPixel(&ptr);
05644 if ( Pixel != ck )
05645 {
05646 Decomposer(Pixel,&R,&G,&B,&A);
05647 Rt += R; Gt += G; Bt += B;
05648 cnt ++;
05649 }
05650 }
05651 ptr += xtra;
05652 }
05653 }
05654 else
05655 {
05656 for(y=h;y--;)
05657 {
05658 for(x=w;x--;)
05659 {
05660 GetColor(&ptr,&R,&G,&B,&A);
05661 if ( A > 80 )
05662 {
05663 Rt += R; Gt += G; Bt += B;
05664 cnt ++;
05665 }
05666 }
05667 ptr += xtra;
05668 }
05669 }
05670 }
05671
05672 if ( pR ) *pR = (Rt + (cnt>>1)) / cnt;
05673 if ( pG ) *pG = (Gt + (cnt>>1)) / cnt;
05674 if ( pB ) *pB = (Bt + (cnt>>1)) / cnt;
05675 }
05676
05677 return GE_TRUE;
05678 }
|
|
|
||||||||||||||||
|
|
Definition at line 3585 of file bitmap.c. References geBitmap::Driver, geBitmap::DriverInfo, GENESISAPI, GENESISCC, geBitmap::Info, NULL, and geBitmap_Info::Palette. Referenced by BumpMap_ComputePalette(), ElectricFx_InitPalette(), geBitmap_BlitData_Sub(), geBitmap_Palette_CreateFromBitmap(), geBitmap_SetFormat(), geBitmap_SetFormatMin(), geBitmapUtil_SetAlphaFromBrightness(), geFont_DrawText(), geFont_DrawTextToBitmap(), Particles_InitPalette(), PlasmaAnimator_CreatePalette(), ProcUtil_SetPaletteFromString(), and Smoke_InitPalette().
03586 {
03587 if ( ! Bmp ) return NULL;
03588
03589 if ( Bmp->Driver && Bmp->DriverInfo.Palette )
03590 {
03591 assert(Bmp->Info.Palette);
03592 return Bmp->DriverInfo.Palette;
03593 }
03594
03595 return Bmp->Info.Palette;
03596 }
|
|
|
Definition at line 3674 of file bitmap.c. References GENESISAPI, GENESISCC, gePixelFormat, and geBitmap::PreferredFormat.
03675 {
03676 if ( ! Bmp ) return 0;
03677 return Bmp->PreferredFormat;
03678 }
|
|
|
|
|
|
Definition at line 1558 of file bitmap.c. References geBitmap::Alpha, geBitmap_Palette::Format, geBitmap_Info::Format, GE_FALSE, GE_TRUE, geBitmap_IsValid(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat_HasGoodAlpha(), gePixelFormat_HasPalette(), geBitmap::Info, and geBitmap_Info::Palette. Referenced by geBitmap_AttachToDriver().
01559 {
01560 assert( geBitmap_IsValid(Bmp) );
01561
01562 if ( Bmp->Alpha )
01563 return GE_TRUE;
01564
01565 if ( gePixelFormat_HasGoodAlpha(Bmp->Info.Format) )
01566 return GE_TRUE;
01567
01568 if ( gePixelFormat_HasPalette(Bmp->Info.Format) && Bmp->Info.Palette )
01569 {
01570 if ( gePixelFormat_HasGoodAlpha(Bmp->Info.Palette->Format) )
01571 return GE_TRUE;
01572 }
01573
01574 return GE_FALSE;
01575 }
|
|
|
Definition at line 2896 of file bitmap.c. References GENESISAPI, GENESISCC, geBitmap_Info::Height, and geBitmap::Info. Referenced by BumpMap_Create(), geEngine_InitFonts(), geFont_AddCharacters(), geFont_DrawText(), geFont_DrawUsingDIB(), Particles_Create(), PlaceLetter(), Plasma_Create(), and RenderTexturedPoint().
02897 {
02898 assert(Bmp);
02899 return(Bmp->Info.Height);
02900 }
|
|
||||||||||||||||||||||||||||||||
|
Definition at line 616 of file bitmap.c. References GE_FALSE, GE_TRUE, geBitmap_CreateLockFromMip(), geBitmap_Destroy(), geBitmap_IsValid(), geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, MAXMIPLEVELS, geBitmap_Info::MinimumMip, and NULL. Referenced by BumpMap_CreateFromHeightMap(), createPaletteFromBitmap(), geBitmap_CreateLockFromMip(), geBitmap_CreateLockFromMipSystem(), geBitmapUtil_CompareBitmaps(), geBitmapUtil_CreateHBITMAP(), and Water_Create().
00624 {
00625 int mip;
00626 geBitmap * Bmp = (geBitmap *)iBmp;
00627
00628 assert( geBitmap_IsValid(Bmp) );
00629 assert( Target);
00630 assert(MaximumMip >= MinimumMip);
00631 assert( &Bmp != Target );
00632
00633 if ( MinimumMip < Bmp->Info.MinimumMip ||
00634 // MaximumMip > Bmp->Info.MaximumMip
00635 MaximumMip >= MAXMIPLEVELS )
00636 {
00637 geErrorLog_AddString(-1,"LockForRead : invalid mip", NULL);
00638 return GE_FALSE;
00639 }
00640
00641 if ( Bmp->LockCount < 0 || Bmp->LockOwner )
00642 {
00643 geErrorLog_AddString(-1,"LockForRead : already locked", NULL);
00644 return GE_FALSE;
00645 }
00646
00647 for(mip=MinimumMip;mip <= MaximumMip;mip ++)
00648 {
00649 Target[ mip - MinimumMip ] = geBitmap_CreateLockFromMip(Bmp,mip, Format,HasColorKey,ColorKey,1);
00650 if ( ! Target[ mip - MinimumMip ] )
00651 {
00652 geErrorLog_AddString(-1,"LockForRead : CreateLockFromMip failed", NULL);
00653 mip--;
00654 while(mip >= MinimumMip )
00655 {
00656 geBitmap_Destroy( & Target[ mip - MinimumMip ] );
00657 mip--;
00658 }
00659 return GE_FALSE;
00660 }
00661 }
00662
00663 return GE_TRUE;
00664 }
|
|
||||||||||||||||||||
|
Definition at line 561 of file bitmap.c. References geBitmap::DriverDataChanged, geBitmap::DriverHandle, geBitmap::DriverInfo, GE_FALSE, GE_TRUE, geBitmap_CreateLockFromMipOnDriver(), geBitmap_CreateLockFromMipSystem(), geBitmap_Destroy(), geBitmap_IsValid(), geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, geBitmap_Info::MaximumMip, MAXMIPLEVELS, geBitmap_Info::MinimumMip, and NULL. Referenced by geBitmap_BlitMipRect(), geBitmap_SetFormat(), geBitmap_Update_DriverToSystem(), geBitmap_Update_SystemToDriver(), and PlasmaAnimator_CreatePlasma().
00566 {
00567 int mip;
00568 geBitmap * Bmp = (geBitmap *)iBmp;
00569
00570 assert( geBitmap_IsValid(Bmp) );
00571 assert( Target);
00572 assert(MaximumMip >= MinimumMip);
00573 assert( &Bmp != Target );
00574
00575 if ( (MinimumMip < Bmp->Info.MinimumMip && MinimumMip < Bmp->DriverInfo.MinimumMip) ||
00576 (MaximumMip >= MAXMIPLEVELS) )
00577 {
00578 geErrorLog_AddString(-1,"LockForRead : invalid mip", NULL);
00579 return GE_FALSE;
00580 }
00581
00582 if ( Bmp->LockCount < 0 || Bmp->LockOwner )
00583 {
00584 geErrorLog_AddString(-1,"LockForRead : already locked", NULL);
00585 return GE_FALSE;
00586 }
00587
00588 for(mip=MinimumMip;mip <= MaximumMip;mip ++)
00589 {
00590 // err on the side of *not* choosing the driver data to read from !
00591 if ( Bmp->DriverHandle && Bmp->DriverDataChanged
00592 && mip <= Bmp->DriverInfo.MaximumMip && mip >= Bmp->DriverInfo.MinimumMip)
00593 {
00594 Target[ mip - MinimumMip ] = geBitmap_CreateLockFromMipOnDriver(Bmp,mip,1);
00595 }
00596 else
00597 {
00598 Target[ mip - MinimumMip ] = geBitmap_CreateLockFromMipSystem(Bmp,mip,1);
00599 }
00600 if ( ! Target[ mip - MinimumMip ] )
00601 {
00602 geErrorLog_AddString(-1,"LockForRead : CreateLockFromMip failed", NULL);
00603 mip--;
00604 while(mip >= MinimumMip )
00605 {
00606 geBitmap_Destroy( & Target[ mip - MinimumMip ] );
00607 mip--;
00608 }
00609 return GE_FALSE;
00610 }
00611 }
00612
00613 return GE_TRUE;
00614 }
|
|
||||||||||||||||||||
|
Definition at line 399 of file bitmap.c. References geBitmap::DriverHandle, geBitmap::DriverInfo, GE_FALSE, GE_TRUE, geBitmap_CreateLockFromMipOnDriver(), geBitmap_CreateLockFromMipSystem(), geBitmap_Destroy(), geBitmap_IsValid(), geBitmap_MakeSystemMips(), geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, geBitmap_Info::MaximumMip, MAXMIPLEVELS, geBitmap_Info::MinimumMip, and NULL. Referenced by geBitmap_BlitMipRect(), geBitmap_Gamma_Apply(), geBitmap_SetFormat(), geBitmap_UpdateMips(), geBitmapUtil_CreateFromHBITMAP(), geBitmapUtil_SetColor(), geFont_DrawUsingDIB(), geWBitmap_Pool_CreateAllWBitmaps(), PlaceLetter(), and Water_ApplyToBitmap().
00404 {
00405 int mip;
00406
00407 assert( geBitmap_IsValid(Bmp) );
00408 assert( Target);
00409 assert(MaximumMip >= MinimumMip);
00410 assert( &Bmp != Target );
00411
00412 if ( Bmp->LockCount || Bmp->LockOwner )
00413 {
00414 geErrorLog_AddString(-1,"LockForWrite : already locked", NULL);
00415 return GE_FALSE;
00416 }
00417
00418 if ( Bmp->DriverHandle )
00419 {
00420 if ( (MinimumMip < Bmp->DriverInfo.MinimumMip) ||
00421 (MaximumMip > Bmp->DriverInfo.MaximumMip) )
00422 {
00423 geErrorLog_AddString(-1,"LockForWrite : Driver : invalid mip", NULL);
00424 return GE_FALSE;
00425 }
00426 }
00427 else
00428 {
00429 if ( (MinimumMip < Bmp->Info.MinimumMip) ||
00430 (MaximumMip >= MAXMIPLEVELS) )
00431 {
00432 geErrorLog_AddString(-1,"LockForWrite : System : invalid mip", NULL);
00433 return GE_FALSE;
00434 }
00435
00436 if ( MaximumMip > Bmp->Info.MaximumMip )
00437 {
00438 if ( ! geBitmap_MakeSystemMips(Bmp,Bmp->Info.MaximumMip,MaximumMip) )
00439 return GE_FALSE;
00440 Bmp->Info.MaximumMip = MaximumMip;
00441 }
00442 }
00443
00444 for(mip=MinimumMip;mip <= MaximumMip;mip ++)
00445 {
00446 if ( Bmp->DriverHandle )
00447 {
00448 Target[ mip - MinimumMip ] = geBitmap_CreateLockFromMipOnDriver(Bmp,mip,-1);
00449 }
00450 else
00451 {
00452 Target[ mip - MinimumMip ] = geBitmap_CreateLockFromMipSystem(Bmp,mip,-1);
00453 }
00454 if ( ! Target[ mip - MinimumMip ] )
00455 {
00456 geErrorLog_AddString(-1,"LockForWrite : CreateLockFromMip failed", NULL);
00457 mip--;
00458 while(mip >= MinimumMip )
00459 {
00460 geBitmap_Destroy( & Target[ mip - MinimumMip ] );
00461 mip--;
00462 }
00463 return GE_FALSE;
00464 }
00465 }
00466
00467 assert( Bmp->LockCount == - (MaximumMip - MinimumMip + 1) );
00468
00469 return GE_TRUE;
00470 }
|
|
||||||||||||||||||||||||
|
Definition at line 472 of file bitmap.c. References geBitmap::DriverHandle, geBitmap::DriverInfo, geBitmap_Info::Format, GE_FALSE, GE_TRUE, geBitmap_CreateLockFromMipOnDriver(), geBitmap_CreateLockFromMipSystem(), geBitmap_Destroy(), geBitmap_IsValid(), geBitmap_MakeSystemMips(), geBitmap_Update_DriverToSystem(), geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, geBitmap_Info::MaximumMip, MAXMIPLEVELS, geBitmap_Info::MinimumMip, and NULL. Referenced by BumpMap_CreateFromHeightMap(), ElectricFx_Shade(), FireAnimator_CreateFire(), geFont_DrawUsingDIB(), Particles_Draw(), PlasmaAnimator_CreatePlasma(), Smoke_Shade(), and Water_ApplyToBitmap().
00478 {
00479 int mip;
00480
00481 assert( geBitmap_IsValid(Bmp) );
00482 assert( Target);
00483 assert(MaximumMip >= MinimumMip);
00484 assert( &Bmp != Target );
00485
00486 if ( Bmp->LockCount || Bmp->LockOwner )
00487 {
00488 geErrorLog_AddString(-1,"LockForWrite : already locked", NULL);
00489 return GE_FALSE;
00490 }
00491
00492 if ( Format != Bmp->Info.Format && Format != Bmp->DriverInfo.Format )
00493 {
00494 geErrorLog_AddString(-1,"LockForWriteFormat : must be System or Driver Format !", NULL);
00495 return GE_FALSE;
00496 }
00497
00498 if ( Format == Bmp->DriverInfo.Format )
00499 {
00500 if ( MinimumMip < Bmp->DriverInfo.MinimumMip || MaximumMip > Bmp->DriverInfo.MaximumMip )
00501 {
00502 geErrorLog_AddString(-1,"LockForWrite : invalid Driver mip", NULL);
00503 return GE_FALSE;
00504 }
00505 }
00506 else
00507 {
00508 assert( Format == Bmp->Info.Format );
00509
00510 if ( Bmp->DriverHandle )
00511 {
00512 if ( ! geBitmap_Update_DriverToSystem(Bmp) )
00513 {
00514 geErrorLog_AddString(-1,"LockForWrite : Update_DriverToSystem", NULL);
00515 return GE_FALSE;
00516 }
00517 }
00518
00519 // create mips?
00520
00521 if ( MinimumMip < Bmp->Info.MinimumMip || MaximumMip >= MAXMIPLEVELS )
00522 {
00523 geErrorLog_AddString(-1,"LockForWrite : invalid System mip", NULL);
00524 return GE_FALSE;
00525 }
00526
00527 if ( ! geBitmap_MakeSystemMips(Bmp,Bmp->Info.MaximumMip,MaximumMip) )
00528 return GE_FALSE;
00529 Bmp->Info.MaximumMip = MaximumMip;
00530 }
00531
00532 for(mip=MinimumMip;mip <= MaximumMip;mip ++)
00533 {
00534 if ( Bmp->DriverHandle && Format == Bmp->DriverInfo.Format )
00535 {
00536 Target[ mip - MinimumMip ] = geBitmap_CreateLockFromMipOnDriver(Bmp,mip,-1);
00537 }
00538 else
00539 {
00540 Target[ mip - MinimumMip ] = geBitmap_CreateLockFromMipSystem(Bmp,mip,-1);
00541 }
00542
00543 if ( ! Target[ mip - MinimumMip ] )
00544 {
00545 geErrorLog_AddString(-1,"LockForWrite : CreateLockFromMip failed", NULL);
00546 mip--;
00547 while(mip >= MinimumMip )
00548 {
00549 geBitmap_Destroy( & Target[ mip - MinimumMip ] );
00550 mip--;
00551 }
00552 return GE_FALSE;
00553 }
00554 }
00555
00556 assert( Bmp->LockCount == - (MaximumMip - MinimumMip + 1) );
00557
00558 return GE_TRUE;
00559 }
|
|
||||||||||||
|
Definition at line 2815 of file bitmap.c. References geBitmap_Info::Format, GENESISAPI, GENESISCC, gePixelFormat_BytesPerPel(), geBitmap_Info::Height, geBitmap::Info, SHIFT_R_ROUNDUP, geBitmap_Info::Stride, and uint32. Referenced by geBitmap_AllocSystemMip(), and geBitmap_CreateFromFile().
02816 {
02817 uint32 bytes;
02818 if ( ! Bmp )
02819 return 0;
02820 bytes = gePixelFormat_BytesPerPel(Bmp->Info.Format) *
02821 SHIFT_R_ROUNDUP(Bmp->Info.Stride,mip) *
02822 SHIFT_R_ROUNDUP(Bmp->Info.Height,mip);
02823 return bytes;
02824 }
|
|
||||||||||||
|
Definition at line 5195 of file bitmap.c. References GE_FALSE, GE_TRUE, geBitmap_Palette_BlitData(), geBitmap_Palette_Lock(), geBitmap_Palette_UnLock(), geBoolean, GENESISAPI, GENESISCC, and gePixelFormat. Referenced by BlitData_DePalettize(), geBitmap_BlitData_Sub(), geBitmap_DetachDriver(), geBitmap_Palette_CreateCopy(), geBitmap_SetPalette(), and geBitmap_Update_DriverToSystem().
05196 {
05197 gePixelFormat FmFormat,ToFormat;
05198 void *FmData,*ToData;
05199 int FmSize,ToSize;
05200 geBoolean Ret;
05201
05202 assert(Fm);
05203 assert(To);
05204 if ( Fm == To )
05205 return GE_TRUE;
05206
05207 if ( ! geBitmap_Palette_Lock((geBitmap_Palette *)Fm,&FmData,&FmFormat,&FmSize) )
05208 return GE_FALSE;
05209
05210 if ( ! geBitmap_Palette_Lock(To,&ToData,&ToFormat,&ToSize) )
05211 {
05212 geBitmap_Palette_UnLock((geBitmap_Palette *)Fm);
05213 return GE_FALSE;
05214 }
05215
05216 if ( FmSize > ToSize )
05217 {
05218 Ret = GE_FALSE;
05219 }
05220 else
05221 {
05222 Ret = geBitmap_Palette_BlitData(FmFormat,FmData,Fm,ToFormat,ToData,To,FmSize);
05223 }
05224
05225 geBitmap_Palette_UnLock((geBitmap_Palette *)Fm);
05226 geBitmap_Palette_UnLock(To);
05227
05228 return Ret;
05229 }
|
|
||||||||||||
|
on a file which is streaming, the sequence of returns looks like : GE_BITMAP_STREAMING_IDLE GE_BITMAP_STREAMING_CHANGED GE_BITMAP_STREAMING_IDLE GE_BITMAP_STREAMING_IDLE GE_BITMAP_STREAMING_CHANGED ... GE_BITMAP_STREAMING_DONE GE_BITMAP_STREAMING_NOT GE_BITMAP_STREAMING_NOT GE_BITMAP_STREAMING_NOT ... Status >= GE_BITMAP_STREAMING_STARTED means streaming has started & is in progress the user should never see _STARTED or _DATADONE Definition at line 4843 of file bitmap.c. References allocate, clear, geBitmap_Palette::Data, geBitmap_Palette::Format, GE_FALSE, geErrorLog_AddString, GENESISAPI, GENESISCC, gePixelFormat_BytesPerPel(), gePixelFormat_GetOperations(), geRam_Allocate, geRam_Free, geBitmap_Palette::HasColorKey, geBitmap_Palette::LockCount, NULL, geBitmap_Palette::RefCount, gePixelFormat_Operations::RMask, and geBitmap_Palette::Size. Referenced by BlitData_DePalettize(), BumpMap_CreateFromHeightMap(), createPalette(), createPaletteFast(), createPaletteGoodSub(), ElectricFx_InitPalette(), geBitmap_AllocPalette(), geBitmap_BlitData_Sub(), geBitmap_DetachDriver(), geBitmap_Palette_CreateCopy(), geBitmap_Palette_CreateFromFile(), geBitmap_ReadFromBMP(), geBitmap_ReadFromTGA(), geFont_AddBitmapBuffer(), geFont_AddCharacters(), geWBitmap_Pool_CreateAllWBitmaps(), Particles_InitPalette(), PlasmaAnimator_CreatePalette(), ProcUtil_SetPaletteFromString(), and Smoke_InitPalette().
04844 {
04845 geBitmap_Palette * P;
04846 int DataBytes;
04847 const gePixelFormat_Operations * ops;
04848
04849 ops = gePixelFormat_GetOperations(Format);
04850 if ( ! ops->RMask )
04851 {
04852 geErrorLog_AddString(-1,"geBitmap_Palette_Create : Invalid format for a palette!", NULL);
04853 return NULL;
04854 }
04855
04856 DataBytes = gePixelFormat_BytesPerPel(Format) * Size;
04857 if ( DataBytes == 0 )
04858 {
04859 geErrorLog_AddString(-1,"geBitmap_Palette_Create : Invalid format for a palette!", NULL);
04860 return NULL;
04861 }
04862
04863 allocate(P);
04864 if ( ! P ) return NULL;
04865 clear(P);
04866
04867 P->Size = Size;
04868 P->Format = Format;
04869 if ( ! (P->Data = geRam_Allocate(DataBytes)) )
04870 {
04871 geRam_Free(P);
04872 return NULL;
04873 }
04874
04875 P->RefCount = 1;
04876 P->LockCount = 0;
04877
04878 P->HasColorKey = GE_FALSE;
04879
04880 return P;
04881 }
|
|
|
Definition at line 4946 of file bitmap.c. References geBitmap_Palette::Driver, geBitmap_Palette::Format, geBitmap_Palette_Copy(), geBitmap_Palette_Create(), geBitmap_Palette_CreateFromDriver(), geBitmap_Palette_Destroy(), GENESISAPI, GENESISCC, NULL, and geBitmap_Palette::Size. Referenced by geBitmap_AllocPalette().
04947 {
04948 geBitmap_Palette * P;
04949
04950 if ( ! Palette )
04951 return NULL;
04952
04953 if ( Palette->Driver )
04954 {
04955 P = geBitmap_Palette_CreateFromDriver(Palette->Driver,Palette->Format,Palette->Size);
04956 }
04957 else
04958 {
04959 P = geBitmap_Palette_Create(Palette->Format,Palette->Size);
04960 }
04961
04962 if ( ! P ) return NULL;
04963
04964 if ( ! geBitmap_Palette_Copy(Palette,P) )
04965 {
04966 geBitmap_Palette_Destroy(&P);
04967 return NULL;
04968 }
04969
04970 return P;
04971 }
|
|
||||||||||||
|
Definition at line 4891 of file bitmap.c. References createPaletteFromBitmap(), geBitmap_GetPalette(), geBitmap_Palette_CreateRef(), GENESISAPI, and GENESISCC. Referenced by geBitmap_SetFormat().
04892 {
04893 geBitmap_Palette * Pal;
04894 Pal = geBitmap_GetPalette(Bmp);
04895 if ( Pal )
04896 {
04897 geBitmap_Palette_CreateRef(Pal);
04898 return Pal;
04899 }
04900 else
04901 {
04902 return createPaletteFromBitmap(Bmp, Slow);
04903 }
04904 }
|
|
|
Definition at line 5381 of file bitmap.c. References geBitmap_Palette::Data, geBitmap_Palette::Format, GE_FALSE, geBitmap_Palette_Create(), geErrorLog_AddString, GENESISAPI, GENESISCC, gePixelFormat, gePixelFormat_BytesPerPel(), geRam_Free, geVFile_Read(), NULL, PALETTE_INFO_FLAG_COMPRESS, PALETTE_INFO_FLAG_SIZE256, PALETTE_INFO_FORMAT_MASK, geBitmap_Palette::Size, and uint8. Referenced by geBitmap_CreateFromFile().
05382 {
05383 geBitmap_Palette * P;
05384 int Size;
05385 gePixelFormat Format;
05386 uint8 flags,b;
05387
05388 if ( ! geVFile_Read(F, &flags, sizeof(flags)) )
05389 return NULL;
05390
05391 Format = flags & PALETTE_INFO_FORMAT_MASK;
05392
05393 if ( flags & PALETTE_INFO_FLAG_SIZE256 )
05394 {
05395 Size = 256;
05396 }
05397 else
05398 {
05399 if ( ! geVFile_Read(F, &b, sizeof(b)) )
05400 return NULL;
05401 Size = b;
05402 }
05403
05404 P = geBitmap_Palette_Create(Format,Size);
05405 if ( ! P )
05406 return NULL;
05407
05408 if ( flags & PALETTE_INFO_FLAG_COMPRESS )
05409 {
05410 geErrorLog_AddString(-1,"Bitmap_Palette_CreateFromFile : codePal failed!",NULL);
05411 return GE_FALSE;
05412 }
05413 else
05414 {
05415 if ( ! geVFile_Read(F, P->Data, gePixelFormat_BytesPerPel(P->Format) * P->Size) )
05416 {
05417 geRam_Free(P);
05418 return NULL;
05419 }
05420 }
05421
05422 return P;
05423 }
|
|
|
Definition at line 4883 of file bitmap.c. References GE_FALSE, GE_TRUE, geBoolean, GENESISAPI, GENESISCC, and geBitmap_Palette::RefCount. Referenced by geBitmap_CreateFromInfo(), geBitmap_CreateLockFromMip(), geBitmap_CreateLockFromMipOnDriver(), geBitmap_CreateLockFromMipSystem(), geBitmap_Palette_CreateFromBitmap(), and geBitmap_SetPalette().
|
|
|
||||||||||||||||||||
|
Definition at line 5132 of file bitmap.c. References GE_FALSE, geBitmap_Palette_BlitData(), geBitmap_Palette_Lock(), geBitmap_Palette_UnLock(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat, and NULL. Referenced by BlitData_FromSeparateAlpha(), createPaletteFromBitmap(), geBitmap_UpdateMips_Data(), geBitmapUtil_SetAlphaFromBrightness(), and palettizePlane().
05133 {
05134 gePixelFormat FmFormat;
05135 const void *FmData;
05136 int FmSize;
05137 geBoolean Ret;
05138
05139 assert(P);
05140 assert(Into);
05141
05142 if ( ! geBitmap_Palette_Lock((geBitmap_Palette *)P,(void **)&FmData,&FmFormat,&FmSize) )
05143 return GE_FALSE;
05144
05145 if ( FmSize < Size )
05146 Size = FmSize;
05147
05148 Ret = geBitmap_Palette_BlitData(FmFormat,FmData,P,Format,Into,NULL,Size);
05149
05150 geBitmap_Palette_UnLock((geBitmap_Palette *)P);
05151
05152 return Ret;
05153 }
|
|
||||||||||||||||
|
Definition at line 5337 of file bitmap.c. References geBitmap_Palette::Data, geBitmap_Palette::Format, GE_FALSE, GE_TRUE, geBitmap_Palette_Lock(), geBitmap_Palette_UnLock(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat, gePixelFormat_BytesPerPel(), gePixelFormat_GetPixel(), and geBitmap_Palette::Size. Referenced by BlitData_DePalettize(), geBitmap_Palette_GetEntryColor(), and geBitmap_SetFormatMin().
05338 {
05339
05340 assert(P);
05341
05342 if ( P->Data )
05343 {
05344 char *Data;
05345
05346 if ( Color >= P->Size )
05347 return GE_FALSE;
05348
05349 Data = (char *)(P->Data) + Color * gePixelFormat_BytesPerPel(P->Format);
05350 *Pixel = gePixelFormat_GetPixel(P->Format,&Data);
05351 }
05352 else
05353 {
05354 char *Data;
05355 gePixelFormat Format;
05356 int Size;
05357
05358 // must cast away const cuz we don't have a lockforread/write on palettes
05359
05360 if ( ! geBitmap_Palette_Lock((geBitmap_Palette *)P,&Data,&Format,&Size) )
05361 return GE_FALSE;
05362
05363 if ( Color >= Size )
05364 {
05365 geBitmap_Palette_UnLock((geBitmap_Palette *)P);
05366 return GE_FALSE;
05367 }
05368
05369 Data += Color * gePixelFormat_BytesPerPel(Format);
05370 *Pixel = gePixelFormat_GetPixel(Format,&Data);
05371
05372 geBitmap_Palette_UnLock((geBitmap_Palette *)P);
05373 }
05374 return GE_TRUE;
05375 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 5260 of file bitmap.c. References A, B, geBitmap_Palette::ColorKey, geBitmap_Palette::ColorKeyIndex, geBitmap_Palette::Format, G, GE_FALSE, GE_TRUE, geBitmap_Palette_GetEntry(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat_DecomposePixel(), geBitmap_Palette::HasColorKey, R, and uint32.
05261 {
05262 uint32 Pixel;
05263 assert(P);
05264 if ( P->HasColorKey )
05265 {
05266 if ( Color == P->ColorKeyIndex )
05267 {
05268 *R = *G = *B = *A = 0;
05269 return GE_TRUE;
05270 }
05271 else
05272 {
05273 if ( ! geBitmap_Palette_GetEntry(P,Color,&Pixel) )
05274 return GE_FALSE;
05275 if ( Pixel == P->ColorKey )
05276 {
05277 *R = *G = *B = *A = 0;
05278 }
05279 else
05280 {
05281 gePixelFormat_DecomposePixel(P->Format,Pixel,R,G,B,A);
05282 }
05283 }
05284 }
05285 else
05286 {
05287 if ( ! geBitmap_Palette_GetEntry(P,Color,&Pixel) )
05288 return GE_FALSE;
05289 gePixelFormat_DecomposePixel(P->Format,Pixel,R,G,B,A);
05290 }
05291 return GE_TRUE;
05292 }
|
|
||||||||||||
|
Definition at line 5155 of file bitmap.c. References geBitmap_Palette::ColorKey, geBitmap_Info::ColorKey, geBitmap_Palette::Format, geBitmap_Info::Format, GE_TRUE, geBoolean, GENESISAPI, GENESISCC, geBitmap_Palette::HasColorKey, geBitmap_Info::HasColorKey, geBitmap_Info::Height, geBitmap_Info::MaximumMip, geBitmap_Info::MinimumMip, NULL, geBitmap_Info::Palette, geBitmap_Palette::Size, geBitmap_Info::Stride, and geBitmap_Info::Width. Referenced by geBitmap_Gamma_Apply().
05156 {
05157 assert(P && pInfo);
05158
05159 pInfo->Width = pInfo->Stride = P->Size;
05160 pInfo->Height = 1;
05161
05162 pInfo->Format = P->Format;
05163 pInfo->HasColorKey = P->HasColorKey;
05164 pInfo->ColorKey = P->ColorKey;
05165 pInfo->MaximumMip = pInfo->MinimumMip = 0;
05166 pInfo->Palette = NULL;
05167
05168 return GE_TRUE;
05169 }
|
|
||||||||||||||||||||
|
Definition at line 4998 of file bitmap.c. References geBitmap_Palette::Data, geBitmap_Palette::Driver, geBitmap_Palette::DriverBits, geBitmap_Palette::DriverHandle, geBitmap_Palette::Format, GE_FALSE, GE_TRUE, geBoolean, GENESISAPI, GENESISCC, geRDriver_THandleInfo::Height, geBitmap_Palette::LockCount, NULL, geRDriver_PixelFormat::PixelFormat, geRDriver_THandleInfo::PixelFormat, geBitmap_Palette::Size, DRV_Driver::THandle_GetInfo, DRV_Driver::THandle_Lock, and geRDriver_THandleInfo::Width. Referenced by BumpMap_ComputePalette(), ElectricFx_InitPalette(), geBitmap_Gamma_Apply(), geBitmap_Palette_Copy(), geBitmap_Palette_GetData(), geBitmap_Palette_GetEntry(), geBitmap_Palette_SetData(), geBitmap_Palette_SetEntry(), geBitmap_Palette_WriteToFile(), geWBitmap_Pool_CreateAllWBitmaps(), Particles_InitPalette(), PlasmaAnimator_CreatePalette(), ProcUtil_SetPaletteFromString(), and Smoke_InitPalette().
04999 {
05000 assert(P);
05001 assert(pBits);
05002
05003 if ( P->LockCount )
05004 return GE_FALSE;
05005 P->LockCount++;
05006
05007 *pBits = NULL;
05008
05009 if ( P->Data )
05010 {
05011 *pBits = P->Data;
05012 if ( pFormat )
05013 *pFormat= P->Format;
05014 if ( pSize )
05015 *pSize = P->Size;
05016 }
05017 else if ( P->DriverHandle )
05018 {
05019 geRDriver_THandleInfo TInfo;
05020
05021 if ( ! P->Driver->THandle_GetInfo(P->DriverHandle,0,&TInfo) )
05022 return GE_FALSE;
05023
05024 if ( TInfo.Height != 1 )
05025 return GE_FALSE;
05026
05027 if ( ! (P->Driver->THandle_Lock(P->DriverHandle,0,pBits)) )
05028 *pBits = NULL;
05029
05030 P->DriverBits = *pBits;
05031
05032 if ( pFormat )
05033 *pFormat = TInfo.PixelFormat.PixelFormat;
05034 if ( pSize )
05035 *pSize = TInfo.Width;
05036 }
05037
05038 return (*pBits) ? GE_TRUE : GE_FALSE;
05039 }
|
|
||||||||||||||||||||
|
Definition at line 5171 of file bitmap.c. References GE_FALSE, geBitmap_Palette_BlitData(), geBitmap_Palette_Lock(), geBitmap_Palette_UnLock(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat, and NULL. Referenced by createPalette(), createPaletteFast(), createPaletteFromBitmap(), createPaletteGoodSub(), geBitmapUtil_SetAlphaFromBrightness(), geFont_DrawText(), and geFont_DrawTextToBitmap().
05172 {
05173 gePixelFormat PalFormat;
05174 void *PalData;
05175 int PalSize;
05176 geBoolean Ret;
05177
05178 assert(P);
05179 assert(From);
05180
05181 if ( ! geBitmap_Palette_Lock(P,&PalData,&PalFormat,&PalSize) )
05182 return GE_FALSE;
05183
05184 if ( PalSize < Colors )
05185 Colors = PalSize;
05186
05187 Ret = geBitmap_Palette_BlitData(Format,From,NULL,PalFormat,PalData,P,Colors);
05188
05189 if ( ! geBitmap_Palette_UnLock(P) )
05190 return GE_FALSE;
05191
05192 return Ret;
05193 }
|
|
||||||||||||||||
|
Definition at line 5294 of file bitmap.c. References geBitmap_Palette::ColorKeyIndex, geBitmap_Palette::Data, geBitmap_Palette::Format, GE_FALSE, GE_TRUE, geBitmap_Palette_Lock(), geBitmap_Palette_UnLock(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat, gePixelFormat_BytesPerPel(), gePixelFormat_PutPixel(), geBitmap_Palette::HasColorKey, and geBitmap_Palette::Size. Referenced by BlitData_DePalettize(), and geBitmap_Palette_SetEntryColor().
05295 {
05296 assert(P);
05297
05298 if ( P->HasColorKey )
05299 {
05300 if ( Color == P->ColorKeyIndex )
05301 return GE_TRUE;
05302 }
05303
05304 if ( P->Data )
05305 {
05306 char *Data;
05307
05308 if ( Color >= P->Size )
05309 return GE_FALSE;
05310
05311 Data = (char *)(P->Data) + Color * gePixelFormat_BytesPerPel(P->Format);
05312 gePixelFormat_PutPixel(P->Format,&Data,Pixel);
05313 }
05314 else
05315 {
05316 char *Data;
05317 gePixelFormat Format;
05318 int Size;
05319
05320 if ( ! geBitmap_Palette_Lock(P,&Data,&Format,&Size) )
05321 return GE_FALSE;
05322
05323 if ( Color >= Size )
05324 {
05325 geBitmap_Palette_UnLock(P);
05326 return GE_FALSE;
05327 }
05328
05329 Data += Color * gePixelFormat_BytesPerPel(Format);
05330 gePixelFormat_PutPixel(Format,&Data,Pixel);
05331
05332 geBitmap_Palette_UnLock(P);
05333 }
05334 return GE_TRUE;
05335 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 5231 of file bitmap.c. References A, B, geBitmap_Palette::ColorKey, geBitmap_Palette::ColorKeyIndex, geBitmap_Palette::Format, G, GE_FALSE, geBitmap_Palette_SetEntry(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat_ComposePixel(), gePixelFormat_HasAlpha(), geBitmap_Palette::HasColorKey, R, and uint32. Referenced by BlitData_DePalettize(), geBitmap_BlitData_Sub(), geFont_AddBitmapBuffer(), and geFont_AddCharacters().
05232 {
05233 assert(P);
05234
05235 if ( A < 80 && ! gePixelFormat_HasAlpha(P->Format) && P->HasColorKey )
05236 {
05237 return geBitmap_Palette_SetEntry(P,Color,P->ColorKey);
05238 }
05239 else if ( P->HasColorKey )
05240 {
05241 uint32 Pixel;
05242
05243 // might have alpha AND colorkey !
05244
05245 if ( Color == P->ColorKeyIndex ) // and A > 80 because of the above
05246 return GE_FALSE;
05247
05248 Pixel = gePixelFormat_ComposePixel(P->Format,R,G,B,A);
05249 if ( Pixel == P->ColorKey )
05250 Pixel ^= 1;
05251
05252 return geBitmap_Palette_SetEntry(P,Color,Pixel);
05253 }
05254 else
05255 {
05256 return geBitmap_Palette_SetEntry(P,Color,gePixelFormat_ComposePixel(P->Format,R,G,B,A));
05257 }
05258 }
|
|
||||||||||||
|
Definition at line 5101 of file bitmap.c. References geBitmap_Palette::Data, geBitmap_Palette::DriverHandle, geBitmap_Palette::Format, GE_FALSE, GE_TRUE, geBitmap_Palette_BlitData(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat_BytesPerPel(), geRam_Allocate, geRam_Free, geBitmap_Palette::HasColorKey, NULL, and geBitmap_Palette::Size. Referenced by geBitmapUtil_SetAlphaFromBrightness().
05102 {
05103 void * NewData;
05104
05105 assert(P);
05106
05107 if ( P->DriverHandle ) // can't change format on card!
05108 return GE_FALSE;
05109
05110 assert( ! P->HasColorKey ); // can't have colorkey accept on Glide
05111
05112 if ( Format == P->Format )
05113 return GE_TRUE;
05114
05115 NewData = geRam_Allocate( gePixelFormat_BytesPerPel(Format) * P->Size );
05116 if ( ! NewData )
05117 return GE_FALSE;
05118
05119 if ( ! geBitmap_Palette_BlitData(P->Format,P->Data,NULL,Format,NewData,NULL,P->Size) )
05120 {
05121 geRam_Free(NewData);
05122 return GE_FALSE;
05123 }
05124
05125 geRam_Free(P->Data);
05126 P->Data = NewData;
05127 P->Format = Format;
05128
05129 return GE_TRUE;
05130 }
|
|
||||||||||||
|
|
|
|
Definition at line 5041 of file bitmap.c. References geBitmap_Palette::ColorKey, geBitmap_Palette::ColorKeyIndex, geBitmap_Palette::Data, geBitmap_Palette::Driver, geBitmap_Palette::DriverBits, geBitmap_Palette::DriverHandle, geBitmap_Palette::Format, GE_FALSE, GE_TRUE, geBoolean, GENESISAPI, GENESISCC, gePixelFormat_GetOperations(), gePixelFormat_PixelGetter, gePixelFormat_PixelPutter, gePixelFormat_Operations::GetPixel, geBitmap_Palette::HasColorKey, geBitmap_Palette::LockCount, NULL, gePixelFormat_Operations::PutPixel, geBitmap_Palette::Size, DRV_Driver::THandle_UnLock, uint32, and uint8. Referenced by BumpMap_ComputePalette(), ElectricFx_InitPalette(), geBitmap_Gamma_Apply(), geBitmap_Palette_Copy(), geBitmap_Palette_GetData(), geBitmap_Palette_GetEntry(), geBitmap_Palette_SetData(), geBitmap_Palette_SetEntry(), geBitmap_Palette_WriteToFile(), geWBitmap_Pool_CreateAllWBitmaps(), Particles_InitPalette(), PlasmaAnimator_CreatePalette(), ProcUtil_SetPaletteFromString(), and Smoke_InitPalette().
05042 {
05043 assert(P);
05044 if ( P->LockCount <= 0 )
05045 return GE_FALSE;
05046 P->LockCount--;
05047 if ( P->LockCount == 0 )
05048 {
05049 if ( P->HasColorKey )
05050 {
05051 if ( P->ColorKeyIndex >= 0 && P->ColorKeyIndex < P->Size )
05052 {
05053 uint8 *Bits=NULL,*pBits=NULL;
05054 uint32 Pixel;
05055 int p;
05056 const gePixelFormat_Operations *ops;
05057 gePixelFormat_PixelPutter PutPixel;
05058 gePixelFormat_PixelGetter GetPixel;
05059
05060 if ( P->Data )
05061 {
05062 Bits = P->Data;
05063 }
05064 else if ( P->DriverBits )
05065 {
05066 Bits = P->DriverBits;
05067 }
05068
05069 ops = gePixelFormat_GetOperations(P->Format);
05070 assert(ops);
05071
05072 GetPixel = ops->GetPixel;
05073 PutPixel = ops->PutPixel;
05074
05075 for(p=0;p<P->Size;p++)
05076 {
05077 pBits = Bits;
05078 Pixel = GetPixel(&Bits);
05079 if ( p == P->ColorKeyIndex )
05080 {
05081 PutPixel(&pBits,P->ColorKey);
05082 }
05083 else if ( Pixel == P->ColorKey )
05084 {
05085 Pixel ^= 1;
05086 PutPixel(&pBits,Pixel);
05087 }
05088 }
05089 }
05090 }
05091 if ( P->DriverHandle )
05092 {
05093 if ( ! P->Driver->THandle_UnLock(P->DriverHandle,0) )
05094 return GE_FALSE;
05095 P->DriverBits = NULL;
05096 }
05097 }
05098 return GE_TRUE;
05099 }
|
|
||||||||||||
|
Definition at line 5425 of file bitmap.c. References GE_FALSE, GE_TRUE, geBitmap_Palette_Lock(), geBitmap_Palette_UnLock(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat, gePixelFormat_BytesPerPel(), geVFile_Write(), geBitmap_Palette::HasColorKey, PALETTE_INFO_FLAG_SIZE256, and uint8. Referenced by geBitmap_WriteToFile().
05426 {
05427 int Size;
05428 gePixelFormat Format;
05429 void *Data;
05430
05431 assert(P);
05432
05433 assert( P->HasColorKey == GE_FALSE ); // system palettes can't have color key!
05434
05435 // we usually write the palette's header in one byte :^)
05436
05437 if ( ! geBitmap_Palette_Lock((geBitmap_Palette *)P,&Data,&Format,&Size) )
05438 return GE_FALSE;
05439
05440 {
05441 uint8 b;
05442
05443 b = Format;
05444 assert( b < 32 );
05445 if ( Size == 256 )
05446 b |= PALETTE_INFO_FLAG_SIZE256;
05447
05448 if ( ! geVFile_Write(F, &b, sizeof(b)) )
05449 {
05450 geBitmap_Palette_UnLock((geBitmap_Palette *)P);
05451 return GE_FALSE;
05452 }
05453
05454 if ( Size != 256 )
05455 {
05456 assert(Size < 256);
05457 b = Size;
05458
05459 if ( ! geVFile_Write(F, &b, sizeof(b)) )
05460 {
05461 geBitmap_Palette_UnLock((geBitmap_Palette *)P);
05462 return GE_FALSE;
05463 }
05464 }
05465 }
05466
05467 if ( ! geVFile_Write(F, Data, gePixelFormat_BytesPerPel(Format) * Size) )
05468 {
05469 geBitmap_Palette_UnLock((geBitmap_Palette *)P);
05470 return GE_FALSE;
05471 }
05472
05473 geBitmap_Palette_UnLock((geBitmap_Palette *)P);
05474
05475 return GE_TRUE;
05476 }
|
|
|
Definition at line 2268 of file bitmap.c. References geBitmap::Data, geBitmap::DataOwner, GE_FALSE, GE_TRUE, geBitmap_IsValid(), geBitmap_UpdateMips(), geBoolean, GENESISAPI, GENESISCC, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, geBitmap_Info::MaximumMip, MAXMIPLEVELS, geBitmap_Info::MinimumMip, and geBitmap::Modified. Referenced by geBitmapUtil_SetColor().
02269 {
02270 int mip;
02271
02272 assert( geBitmap_IsValid(Bmp) );
02273
02274 if ( Bmp->LockOwner || Bmp->LockCount || Bmp->DataOwner )
02275 return GE_FALSE;
02276
02277 for(mip = (Bmp->Info.MinimumMip + 1);mip <= Bmp->Info.MaximumMip;mip++)
02278 {
02279 if ( Bmp->Data[mip] && !(Bmp->Modified[mip]) )
02280 {
02281 int src;
02282 src = mip-1;
02283 while( ! Bmp->Data[src] )
02284 {
02285 src--;
02286 if ( src < Bmp->Info.MinimumMip )
02287 return GE_FALSE;
02288 }
02289 if ( ! geBitmap_UpdateMips(Bmp,src,mip) )
02290 return GE_FALSE;
02291 }
02292 }
02293
02294 #if 0 // never turn off a modified flag
02295 for(mip=0;mip<MAXMIPLEVELS;mip++)
02296 Bmp->Modified[mip] = GE_FALSE;
02297 #endif
02298
02299 return GE_TRUE;
02300 }
|
|
||||||||||||
|
||||||||||||||||||||
|
Definition at line 3322 of file bitmap.c. References geBitmap_Info::ColorKey, geBitmap::Data, geBitmap::DataOwner, geBitmap::DriverHandle, geBitmap_Info::Format, GE_FALSE, GE_TRUE, geBitmap_IsValid(), geBitmap_Update_DriverToSystem(), geBitmap_Update_SystemToDriver(), geBitmap_UsesColorKey(), geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, gePixelFormat_BytesPerPel(), gePixelFormat_HasAlpha(), geBitmap_Info::HasColorKey, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, NULL, and uint32. Referenced by BumpMap_Create(), geEngine_InitFonts(), geFont_AddBitmapBuffer(), geFont_AddCharacters(), geFont_DrawUsingDIB(), geWBitmap_Pool_CreateAllWBitmaps(), GMenu_Create(), SetupConsole(), Smoke_InitBitmap(), and Text_Create().
03323 {
03324 assert( geBitmap_IsValid(Bmp) );
03325
03326 if ( Bmp->LockOwner || Bmp->LockCount || Bmp->DataOwner )
03327 {
03328 geErrorLog_AddString(-1,"SetColorKey : not an original bitmap", NULL);
03329 return GE_FALSE;
03330 }
03331
03332 // see comments in SetFormat
03333
03334 if ( Bmp->DriverHandle )
03335 geBitmap_Update_DriverToSystem(Bmp);
03336
03337 if ( HasColorKey &&
03338 ((uint32)ColorKey>>1) >= ((uint32)1<<(gePixelFormat_BytesPerPel(Bmp->Info.Format)*8 - 1)) )
03339 {
03340 geErrorLog_AddString(-1,"geBitmap_SetColorKey : invalid ColorKey pixel!", NULL);
03341 return GE_FALSE;
03342 }
03343 if ( HasColorKey && gePixelFormat_HasAlpha(Bmp->Info.Format) )
03344 {
03345 geErrorLog_AddString(-1,"geBitmap_SetColorKey : non-fatal : Alpha and ColorKey together won't work right", NULL);
03346 }
03347
03348 if ( HasColorKey && Smart && Bmp->Data[0] )
03349 {
03350 Bmp->Info.HasColorKey = GE_TRUE;
03351 Bmp->Info.ColorKey = ColorKey;
03352 if ( ! geBitmap_UsesColorKey(Bmp) )
03353 {
03354 Bmp->Info.HasColorKey = GE_FALSE;
03355 Bmp->Info.ColorKey = 1;
03356 }
03357 }
03358 else
03359 {
03360 Bmp->Info.HasColorKey = HasColorKey;
03361 Bmp->Info.ColorKey = ColorKey;
03362 }
03363
03364 if ( Bmp->DriverHandle )
03365 geBitmap_Update_SystemToDriver(Bmp);
03366
03367 return GE_TRUE;
03368 }
|
|
||||||||||||||||||||||||
|
Definition at line 3094 of file bitmap.c. References geBitmap::Alpha, geBitmap_Info::ColorKey, geBitmap::Data, geBitmap::DataOwner, geBitmap::Driver, geBitmap::DriverHandle, geBitmap::DriverInfo, geBitmap_Info::Format, GE_FALSE, GE_PIXELFORMAT_WAVELET, GE_TRUE, geBitmap_AllocSystemMip(), geBitmap_AttachToDriver(), geBitmap_BlitData(), geBitmap_ClearMips(), geBitmap_Destroy(), geBitmap_DetachDriver(), geBitmap_GetBits(), geBitmap_GetPalette(), geBitmap_IsValid(), geBitmap_LockForReadNative(), geBitmap_LockForWrite(), geBitmap_Palette_CreateFromBitmap(), geBitmap_Palette_Destroy(), geBitmap_SetPalette(), geBitmap_UnLock(), geBitmap_UpdateMips(), geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, gePixelFormat_BytesPerPel(), gePixelFormat_HasGoodAlpha(), gePixelFormat_HasPalette(), geRam_Free, geBitmap_Info::HasColorKey, geBitmap_Info::Height, geBitmap::Info, geBitmap::LockCount, geBitmap::LockOwner, max, geBitmap_Info::MaximumMip, geBitmap_Info::MinimumMip, NULL, geBitmap_Info::Stride, and geBitmap_Info::Width. Referenced by BumpMap_CreateFromHeightMap(), ElectricFx_InitBitmap(), Fire_Create(), geBitmap_SetFormatMin(), geFont_DrawUsingDIB(), Particles_InitBitmap(), Plasma_Create(), Smoke_InitBitmap(), and Water_Create().
03098 {
03099 assert( geBitmap_IsValid(Bmp) );
03100
03101 if ( Bmp->LockOwner || Bmp->LockCount || Bmp->DataOwner )
03102 {
03103 geErrorLog_AddString(-1,"SetFormat : not an original bitmap", NULL);
03104 return GE_FALSE;
03105 }
03106 // can't do _SetFormat on a locked mip, cuz it would change the size of all the locked mips = no good
03107
03108 // always affects the non-Driver copy
03109
03110 if ( NewFormat == GE_PIXELFORMAT_WAVELET )
03111 {
03112 geErrorLog_AddString(-1,"Genesis3D 1.0 does not support Wavelet Images",NULL);
03113 return GE_FALSE;
03114 }
03115
03116 if ( NewFormat == Bmp->Info.Format )
03117 {
03118 // but not wavelet
03119
03120 if ( gePixelFormat_HasPalette(NewFormat) && Palette )
03121 {
03122 if ( ! geBitmap_SetPalette(Bmp,(geBitmap_Palette *)Palette) )
03123 return GE_FALSE;
03124 }
03125
03126 if ( (! HasColorKey )
03127 || ( HasColorKey && Bmp->Info.HasColorKey && ColorKey == Bmp->Info.ColorKey ) )
03128 {
03129 Bmp->Info.HasColorKey = HasColorKey;
03130 Bmp->Info.ColorKey = ColorKey;
03131 return GE_TRUE;
03132 }
03133 else
03134 {
03135 geBitmap_Info OldInfo;
03136
03137 OldInfo = Bmp->Info;
03138
03139 assert(HasColorKey);
03140
03141 // just change the colorkey
03142
03143 Bmp->Info.HasColorKey = HasColorKey;
03144 Bmp->Info.ColorKey = ColorKey;
03145
03146 if ( Bmp->Data[Bmp->Info.MinimumMip] == NULL )
03147 return GE_TRUE;
03148
03149 assert(Bmp->Info.MinimumMip == 0); //{} this is just out of laziness
03150
03151 // _SetFormat : same format
03152 if ( ! geBitmap_BlitData( &OldInfo, Bmp->Data[Bmp->Info.MinimumMip], NULL,
03153 &(Bmp->Info), Bmp->Data[Bmp->Info.MinimumMip], NULL,
03154 Bmp->Info.Width, Bmp->Info.Height) )
03155 {
03156 return GE_FALSE;
03157 }
03158
03159 return GE_TRUE;
03160 }
03161 }
03162 else
03163 {
03164 geBitmap_Info OldInfo;
03165 int OldBPP,NewBPP;
03166 int OldMaxMips;
03167 DRV_Driver * Driver;
03168
03169 if ( gePixelFormat_HasPalette(NewFormat) )
03170 {
03171 if ( Palette )
03172 {
03173 if ( ! geBitmap_SetPalette(Bmp,(geBitmap_Palette *)Palette) )
03174 return GE_FALSE;
03175 }
03176 else
03177 {
03178 if ( ! geBitmap_GetPalette(Bmp) && ! gePixelFormat_HasPalette(Bmp->Info.Format) )
03179 {
03180 geBitmap_Palette *NewPal;
03181 NewPal = geBitmap_Palette_CreateFromBitmap(Bmp,GE_FALSE);
03182 if ( ! NewPal )
03183 {
03184 geErrorLog_AddString(-1,"_SetFormat : createPaletteFromBitmap failed", NULL);
03185 return GE_FALSE;
03186 }
03187 if ( ! geBitmap_SetPalette(Bmp,NewPal) )
03188 return GE_FALSE;
03189 geBitmap_Palette_Destroy(&NewPal);
03190 }
03191 }
03192 }
03193
03194 Driver = Bmp->Driver;
03195 if ( Driver )
03196 if ( ! geBitmap_DetachDriver(Bmp,GE_TRUE) )
03197 return GE_FALSE;
03198
03199 OldBPP = gePixelFormat_BytesPerPel(Bmp->Info.Format);
03200 NewBPP = gePixelFormat_BytesPerPel(NewFormat);
03201
03202 OldInfo = Bmp->Info;
03203 Bmp->Info.Format = NewFormat;
03204 Bmp->Info.HasColorKey = HasColorKey;
03205 Bmp->Info.ColorKey = ColorKey;
03206
03207 // {} this is not very polite; we do restore them later, though...
03208 OldMaxMips = max(Bmp->Info.MaximumMip,Bmp->DriverInfo.MaximumMip);
03209 geBitmap_ClearMips(Bmp);
03210
03211 if ( Bmp->Data[Bmp->Info.MinimumMip] == NULL &&
03212 Bmp->DriverHandle == NULL )
03213 return GE_TRUE;
03214
03215 if ( OldBPP == NewBPP )
03216 {
03217 geBitmap * Lock;
03218 void * Bits;
03219 // can work in place
03220 if ( ! geBitmap_LockForWrite(Bmp,&Lock,0,0) )
03221 return GE_FALSE;
03222
03223 if ( ! (Bits = geBitmap_GetBits(Lock)) )
03224 {
03225 geBitmap_UnLock(Lock);
03226 return GE_FALSE;
03227 }
03228
03229 // _SetFormat : new format
03230 if ( ! geBitmap_BlitData( &OldInfo, Bits, Lock,
03231 &(Lock->Info), Bits, Lock,
03232 Lock->Info.Width, Lock->Info.Height) )
03233 {
03234 geBitmap_UnLock(Lock);
03235 return GE_FALSE;
03236 }
03237
03238 geBitmap_UnLock(Lock);
03239 }
03240 else // NewFormat is raw && != OldFormat
03241 {
03242 geBitmap OldBmp;
03243 geBitmap *Lock,*SrcLock;
03244 void *Bits,*OldBits;
03245
03246 OldBmp = *Bmp;
03247 OldBmp.Info = OldInfo;
03248
03249 // clear out the Bmp for putting the new format in
03250 Bmp->Info.Stride = Bmp->Info.Width;
03251 Bmp->Data[0] = NULL;
03252 Bmp->Alpha = NULL;
03253
03254 if ( ! geBitmap_AllocSystemMip(Bmp,0) )
03255 return GE_FALSE;
03256
03257 if ( ! geBitmap_LockForReadNative(&OldBmp,&SrcLock,0,0) )
03258 return GE_FALSE;
03259
03260 if ( ! geBitmap_LockForWrite(Bmp,&Lock,0,0) )
03261 return GE_FALSE;
03262
03263 if ( ! (Bits = geBitmap_GetBits(Lock)) )
03264 {
03265 geBitmap_UnLock(Lock);
03266 return GE_FALSE;
03267 }
03268 if ( ! (OldBits = geBitmap_GetBits(SrcLock)) )
03269 {
03270 geBitmap_UnLock(Lock);
03271 return GE_FALSE;
03272 }
03273
03274 // _SetFormat : new format
03275 if ( ! geBitmap_BlitData( &OldInfo, OldBits, SrcLock,
03276 &(Lock->Info), Bits, Lock,
03277 Lock->Info.Width, Lock->Info.Height) )
03278 {
03279 // try to undo as well as possible
03280 return GE_FALSE;
03281 }
03282
03283 geBitmap_UnLock(Lock);
03284 geBitmap_UnLock(SrcLock);
03285
03286 if ( OldBmp.Data[0] )
03287 {
03288 geRam_Free(OldBmp.Data[0]);
03289 OldBmp.Data[0] = NULL;
03290 }
03291
03292 if ( gePixelFormat_HasGoodAlpha(NewFormat) )
03293 {
03294 geBitmap_Destroy(&(OldBmp.Alpha));
03295 }
03296 else
03297 {
03298 Bmp->Alpha = OldBmp.Alpha;
03299 }
03300 }
03301
03302 {
03303 int mip;
03304 mip = Bmp->Info.MinimumMip;
03305 while( mip < OldMaxMips )
03306 {
03307 geBitmap_UpdateMips(Bmp,mip,mip+1);
03308 mip++;
03309 }
03310 }
03311
03312 if ( Driver )
03313 {
03314 if ( ! geBitmap_AttachToDriver(Bmp,Driver,0) )
03315 return GE_FALSE;
03316 }
03317 }
03318
03319 return GE_TRUE;
03320 }
|
|
||||||||||||
|
Definition at line 3050 of file bitmap.c. References geBitmap_Info::ColorKey, geBitmap_Palette::Format, geBitmap_Info::Format, GE_FALSE, GE_TRUE, geBitmap_GetPalette(), geBitmap_IsValid(), geBitmap_Palette_GetEntry(), geBitmap_SetFormat(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat_ConvertPixel(), gePixelFormat_HasPalette(), gePixelFormat_IsRaw(), geBitmap_Info::HasColorKey, geBitmap::Info, and uint32. Referenced by SetFormat_Create().
03051 {
03052 geBitmap_Palette * Pal;
03053
03054 assert(geBitmap_IsValid(Bmp));
03055
03056 Pal = geBitmap_GetPalette(Bmp);
03057 if ( Bmp->Info.HasColorKey )
03058 {
03059 uint32 CK=0;
03060 if ( gePixelFormat_IsRaw(NewFormat) )
03061 {
03062 if ( gePixelFormat_IsRaw(Bmp->Info.Format) )
03063 {
03064 CK = gePixelFormat_ConvertPixel(Bmp->Info.Format,Bmp->Info.ColorKey,NewFormat);
03065 }
03066 else if ( gePixelFormat_HasPalette(Bmp->Info.Format) )
03067 {
03068 assert(Pal);
03069 geBitmap_Palette_GetEntry(Pal,Bmp->Info.ColorKey,&CK);
03070 CK = gePixelFormat_ConvertPixel(Pal->Format,CK,NewFormat);
03071 if ( ! CK ) CK = 1;
03072 }
03073 }
03074 else
03075 {
03076 if ( gePixelFormat_HasPalette(NewFormat) )
03077 {
03078 CK = 255;
03079 }
03080 else
03081 {
03082 CK = 1;
03083 }
03084 }
03085
03086 return geBitmap_SetFormat(Bmp,NewFormat,GE_TRUE,CK,Pal);
03087 }
03088 else
03089 {
03090 return geBitmap_SetFormat(Bmp,NewFormat,GE_FALSE,0,Pal);
03091 }
03092 }
|
|
||||||||||||||||
|
Definition at line 1848 of file bitmap.c. References geBitmap::DriverGamma, geBitmap::DriverGammaLast, geBitmap::DriverGammaSet, geBitmap::DriverHandle, geBitmap_Info::Format, GE_FALSE, GE_TRUE, geBitmap_Gamma_Apply(), geBitmap_IsValid(), geBitmap_Update_DriverToSystem(), geBitmap_Update_SystemToDriver(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat_BytesPerPel(), and geBitmap::Info. Referenced by BitmapList_SetGamma(), BumpMap_ComputePalette(), FireAnimator_CreateFire(), Particles_Draw(), and PlasmaAnimator_CreatePlasma().
01849 {
01850 assert(geBitmap_IsValid(Bmp));
01851 assert( Gamma > 0.0f );
01852
01853 /***
01854
01855 there are actually some anomalies involved in exposing this to the user:
01856 if the driver's gamma correction is turned on, then this Gamma will be applied *in addition* to the driver gamma.
01857 There's no easy way to avoid that problem.
01858
01859 we like to expose this to the user so that they can disable software gamma correction on some bitmaps
01860 (eg. procedurals)
01861 perhaps provide a Bitmap_DisableGamma(Bmp) instead of SetGamma ?
01862
01863 **/
01864
01865 if ( Apply && Bmp->DriverHandle )
01866 {
01867 if ( fabs(Bmp->DriverGamma - Gamma) > 0.1f )
01868 {
01869 if ( gePixelFormat_BytesPerPel(Bmp->Info.Format) == 0 && Bmp->DriverHandle )
01870 {
01871 // system format is compressed, and Bmp is on the card
01872
01873 if ( (Bmp->DriverGammaLast >= Bmp->DriverGamma && Bmp->DriverGamma >= Gamma) ||
01874 (Bmp->DriverGammaLast <= Bmp->DriverGamma && Bmp->DriverGamma <= Gamma) )
01875 {
01876 // moving in the same direction
01877
01878 // invert the old
01879 if ( ! geBitmap_Gamma_Apply(Bmp,GE_TRUE) )
01880 return GE_FALSE;
01881
01882 Bmp->DriverGammaLast = Bmp->DriverGamma;
01883 Bmp->DriverGamma = Gamma;
01884
01885 // apply the new
01886 if ( ! geBitmap_Gamma_Apply(Bmp,GE_FALSE) )
01887 return GE_FALSE;
01888 }
01889 else
01890 {
01891 // changed direction so must do an update
01892
01893 if ( ! geBitmap_Update_DriverToSystem(Bmp) )
01894 return GE_FALSE;
01895
01896 Bmp->DriverGammaLast = Bmp->DriverGamma = Gamma;
01897
01898 if ( ! geBitmap_Update_SystemToDriver(Bmp) )
01899 return GE_FALSE;
01900 }
01901 }
01902 else
01903 {
01904 if ( ! geBitmap_Update_DriverToSystem(Bmp) )
01905 return GE_FALSE;
01906
01907 Bmp->DriverGammaLast = Bmp->DriverGamma = Gamma;
01908
01909 if ( ! geBitmap_Update_SystemToDriver(Bmp) )
01910 return GE_FALSE;
01911 }
01912 }
01913 }
01914 else
01915 {
01916 Bmp->DriverGamma = Gamma;
01917 }
01918 Bmp->DriverGammaSet = GE_TRUE;
01919
01920 return GE_TRUE;
01921 }
|
|
||||||||||||
|
Definition at line 2730 of file bitmap.c. References geBitmap::DataOwner, geBitmap::Driver, GE_FALSE, GE_TRUE, geBitmap_AttachToDriver(), geBitmap_DetachDriver(), geBitmap_IsValid(), geBoolean, GENESISAPI, GENESISCC, geBitmap::LockCount, geBitmap::LockOwner, NULL, and geBitmap::SeekMipCount. Referenced by geBody_CreateFromFile().
02731 {
02732 DRV_Driver * Driver;
02733
02734 assert( geBitmap_IsValid(Bmp) );
02735
02736 if ( Bmp->LockOwner || Bmp->LockCount || Bmp->DataOwner )
02737 return GE_FALSE;
02738
02739 if ( Bmp->SeekMipCount == Count )
02740 {
02741 Driver = NULL;
02742 }
02743 else
02744 {
02745 Driver = Bmp->Driver;
02746 if ( Driver )
02747 {
02748 if ( ! geBitmap_DetachDriver(Bmp,GE_TRUE) )
02749 return GE_FALSE;
02750 }
02751 assert(Bmp->Driver == NULL);
02752 }
02753
02754 Bmp->SeekMipCount = Count;
02755
02756 // @@ don't do this ?
02757 // if ( Bmp->Info.MaximumMip < (Count-1) )
02758 // geBitmap_MakeSystemMips(Bmp,0,Count-1);
02759 //
02760
02761 if ( Driver )
02762 {
02763 if ( ! geBitmap_AttachToDriver(Bmp,Driver,0) )
02764 return GE_FALSE;
02765 }
02766
02767 return GE_TRUE;
02768 }
|
|
||||||||||||
|
Definition at line 3493 of file bitmap.c. References geBitmap_Info::ColorKey, geBitmap_Palette::ColorKeyIndex, geBitmap::Driver, geBitmap_Palette::Driver, geBitmap::DriverDataChanged, geBitmap::DriverHandle, geBitmap::DriverInfo, geBitmap_Info::Format, geBitmap_Palette::Format, GE_FALSE, GE_TRUE, geBitmap_AllocPalette(), geBitmap_IsValid(), geBitmap_Palette_Copy(), geBitmap_Palette_CreateRef(), geBitmap_Palette_Destroy(), geBitmap_Palette_IsValid(), geBitmap_Update_SystemToDriver(), geBoolean, GENESISAPI, GENESISCC, gePixelFormat_HasPalette(), geBitmap_Palette::HasColorKey, geBitmap::Info, geBitmap::LockOwner, NULL, geBitmap_Info::Palette, and uint32. Referenced by BumpMap_ComputePalette(), BumpMap_CreateFromHeightMap(), ElectricFx_InitPalette(), geBitmap_BlitData_Sub(), geBitmap_SetFormat(), geBitmap_UnLock_Internal(), geBitmap_Update_SystemToDriver(), geFont_AddBitmapBuffer(), geFont_AddCharacters(), geFont_DrawText(), geFont_DrawTextToBitmap(), geWBitmap_Pool_CreateAllWBitmaps(), Particles_InitPalette(), PlasmaAnimator_CreatePalette(), ProcUtil_SetPaletteFromString(), and Smoke_InitPalette().
03494 {
03495 assert(Bmp); // not nec. valid
03496 assert( geBitmap_Palette_IsValid(Palette) );
03497
03498 if ( Bmp->LockOwner )
03499 Bmp = Bmp->LockOwner;
03500
03501 /* //{} breaks PalCreate
03502 if ( Bmp->LockCount > 0 || Bmp->DataOwner )
03503 {
03504 geErrorLog_AddString(-1,"SetPalette : not an original bitmap", NULL);
03505 return GE_FALSE;
03506 }
03507 */
03508
03509 // warning : Bitmap_Blitdata calls us when it auto-creates a palette!
03510
03511 // note that when we _SetPalette on a bitmap, all its write-locked children
03512 // also get new palettes
03513
03514 if ( Bmp->Info.Palette != Palette )
03515 {
03516 // save the palette even if we're not palettized, for later use
03517 if ( Palette->Driver )
03518 {
03519 if ( ! geBitmap_AllocPalette(Bmp,Palette->Format,NULL) )
03520 return GE_FALSE;
03521
03522 if ( ! geBitmap_Palette_Copy(Palette,Bmp->Info.Palette) )
03523 return GE_FALSE;
03524 }
03525 else
03526 {
03527 if ( Bmp->Info.Palette )
03528 geBitmap_Palette_Destroy(&(Bmp->Info.Palette));
03529
03530 Bmp->Info.Palette = (geBitmap_Palette *)Palette;
03531 geBitmap_Palette_CreateRef(Bmp->Info.Palette);
03532 }
03533 }
03534
03535 if ( gePixelFormat_HasPalette(Bmp->DriverInfo.Format) &&
03536 Bmp->DriverInfo.Palette != Palette )
03537 {
03538 if ( Palette->Driver == Bmp->Driver &&
03539 ( ! Palette->HasColorKey || ! Bmp->DriverInfo.ColorKey ||
03540 (uint32)Palette->ColorKeyIndex == Bmp->DriverInfo.ColorKey ) )
03541 {
03542 if ( Bmp->DriverInfo.Palette )
03543 geBitmap_Palette_Destroy(&(Bmp->DriverInfo.Palette));
03544 Bmp->DriverInfo.Palette = (geBitmap_Palette *)Palette;
03545 geBitmap_Palette_CreateRef(Bmp->DriverInfo.Palette);
03546 }
03547 else if ( Bmp->DriverInfo.Palette )
03548 {
03549 if ( ! geBitmap_Palette_Copy(Palette,Bmp->DriverInfo.Palette) )
03550 return GE_FALSE;
03551 }
03552 else
03553 {
03554 if ( ! geBitmap_AllocPalette(Bmp,0,Bmp->Driver) )
03555 return GE_FALSE;
03556
03557 if ( ! geBitmap_Palette_Copy(Palette,Bmp->DriverInfo.Palette) )
03558 return GE_FALSE;
03559 }
03560 }
03561
03562 if ( Bmp->DriverHandle )
03563 {
03564 // if one has pal and other doesn't this is real change!
03565 if ( gePixelFormat_HasPalette(Bmp->Info.Format) &&
03566 ! gePixelFormat_HasPalette(Bmp->DriverInfo.Format) )
03567 {
03568 // this over-rides any driver changes!
03569 Bmp->DriverDataChanged = GE_FALSE;
03570 if ( ! geBitmap_Update_SystemToDriver(Bmp) )
03571 return GE_FALSE;
03572 }
03573 else if ( ! gePixelFormat_HasPalette(Bmp->Info.Format) &&
03574 gePixelFormat_HasPalette(Bmp->DriverInfo.Format) )
03575 {
03576 Bmp->DriverDataChanged = GE_TRUE;
03577 }
03578 }
03579
03580 assert( geBitmap_IsValid(Bmp) );
03581
03582 return GE_TRUE;
03583 }
|
|
||||||||||||
|
|
Definition at line 802 of file bitmap.c. References GE_TRUE, geBitmap_UnLock_Internal(), geBoolean, GENESISAPI, and GENESISCC. Referenced by BumpMap_CreateFromHeightMap(), createPaletteFromBitmap(), ElectricFx_Shade(), FireAnimator_CreateFire(), geBitmap_BlitMipRect(), geBitmap_Destroy(), geBitmap_SetFormat(), geBitmap_UnLock_Internal(), geBitmap_UnLockArray(), geBitmap_Update_DriverToSystem(), geBitmapUtil_CompareBitmaps(), geBitmapUtil_CreateFromHBITMAP(), geBitmapUtil_CreateHBITMAP(), geBitmapUtil_SetColor(), geFont_DrawUsingDIB(), geWBitmap_Pool_CreateAllWBitmaps(), Particles_Draw(), PlaceLetter(), PlasmaAnimator_CreatePlasma(), Smoke_Shade(), Water_ApplyToBitmap(), and Water_Create().
00803 {
00804 return geBitmap_UnLock_Internal(Bmp,GE_TRUE);
00805 }
|
|
||||||||||||
|
Definition at line 679 of file bitmap.c. References GE_FALSE, GE_TRUE, geBitmap_UnLock(), geBoolean, GENESISAPI, and GENESISCC. Referenced by geBitmap_Update_SystemToDriver().
00680 {
00681 int i;
00682 geBoolean Ret = GE_TRUE;
00683 assert(Locks);
00684 for(i=0;i<Size;i++)
00685 {
00686 if ( ! geBitmap_UnLock(Locks[i]) )
00687 Ret = GE_FALSE;
00688 }
00689 return Ret;
00690 }
|
|
||||||||||||||||
|
Definition at line 2302 of file bitmap.c. References geBitmap::DataOwner, geBitmap::DriverHandle, GE_FALSE, geBitmap_GetBits(), geBitmap_GetInfo(), geBitmap_IsValid(), geBitmap_LockForWrite(), geBitmap_UnLockArray_NoChange(), geBitmap_UpdateMips_Data(), geBitmap_UpdateMips_System(), geBoolean, GENESISAPI, GENESISCC, geBitmap::LockCount, geBitmap::LockOwner, MAXMIPLEVELS, and NULL. Referenced by geBitmap_RefreshMips(), geBitmap_SetFormat(), and geBitmap_Update_SystemToDriver().
02303 {
02304 geBitmap * Locks[MAXMIPLEVELS];
02305 void *FmBits,*ToBits;
02306 geBitmap_Info FmInfo,ToInfo;
02307 geBoolean Ret = GE_FALSE;
02308
02309 assert( geBitmap_IsValid(Bmp) );
02310
02311 if ( Bmp->LockOwner || Bmp->LockCount > 0 || Bmp->DataOwner )
02312 return GE_FALSE;
02313
02314 if ( fm >= to )
02315 return GE_FALSE;
02316
02317 if ( Bmp->DriverHandle )
02318 {
02319 //{} this version does *NOT* make new mips if to > Bmp->DriverInfo.MaximumMip
02320
02321 if ( ! geBitmap_LockForWrite(Bmp,Locks,fm,to) )
02322 return GE_FALSE;
02323
02324 if ( geBitmap_GetInfo(Locks[0],&FmInfo,NULL) && geBitmap_GetInfo(Locks[to - fm],&ToInfo,NULL) )
02325 {
02326 FmBits = geBitmap_GetBits(Locks[0]);
02327 ToBits = geBitmap_GetBits(Locks[to - fm]);
02328
02329 if ( FmBits && ToBits )
02330 {
02331 Ret = geBitmap_UpdateMips_Data( &FmInfo, FmBits,
02332 &ToInfo, ToBits );
02333 }
02334 }
02335
02336 geBitmap_UnLockArray_NoChange(Locks,to - fm + 1);
02337 }
02338 else
02339 {
02340 Ret = geBitmap_UpdateMips_System(Bmp,fm,to);
02341 }
02342
02343 return Ret;
02344 }
|
|
|
Definition at line 2890 of file bitmap.c. References GENESISAPI, GENESISCC, geBitmap::Info, and geBitmap_Info::Width. Referenced by BumpMap_Create(), geEngine_InitFonts(), geFont_AddCharacters(), geFont_DrawText(), geFont_DrawUsingDIB(), Particles_Create(), PlaceLetter(), Plasma_Create(), and RenderTexturedPoint().
02891 {
02892 assert(Bmp);
02893 return(Bmp->Info.Width);
02894 }
|
|
||||||||||||
|
Definition at line 3894 of file bitmap.c. References geBitmap::Alpha, geBitmap::Data, geBitmap::DriverHandle, geBitmap_Info::Format, GE_FALSE, GE_PIXELFORMAT_WAVELET, GE_TRUE, GE_VFILE_OPEN_CREATE, geBitmap_IsValid(), geBitmap_Palette_WriteToFile(), geBitmap_Update_DriverToSystem(), geBitmap_WriteInfo(), GEBM_TAG, GEBM_VERSION, geBmTag_t, geBoolean, geErrorLog_AddString, GENESISAPI, GENESISCC, gePixelFormat_BytesPerPel(), geRam_Allocate, geRam_Free, geVFile_Close(), geVFile_OpenNewSystem(), geVFile_Write(), geBitmap_Info::Height, geBitmap::Info, geBitmap_Info::MaximumMip, geBitmap_Info::MinimumMip, MIP_FLAG_COMPRESSED, MIP_MASK, geBitmap::Modified, NULL, geBitmap_Info::Palette, s, SHIFT_R_ROUNDUP, geBitmap_Info::Stride, uint32, uint8, geBitmap_Info::Width, and y. Referenced by geBitmap_WriteToFileName(), and geBody_WriteToFile().
03895 {
03896 geBmTag_t geBM_Tag;
03897 uint8 geBM_Version;
03898 uint8 flags;
03899 int mip;
03900
03901 assert(Bmp && F);
03902 assert( geBitmap_IsValid(Bmp) );
03903
03904 geBM_Tag = GEBM_TAG;
03905 geBM_Version = GEBM_VERSION;
03906
03907 if ( Bmp->DriverHandle )
03908 {
03909 if ( ! geBitmap_Update_DriverToSystem((geBitmap *)Bmp) )
03910 {
03911 geErrorLog_AddString(-1,"WriteToFile : Update_DriverToSystem", NULL);
03912 return GE_FALSE;
03913 }
03914 }
03915
03916 if ( ! geVFile_Write(F, &geBM_Tag, sizeof(geBM_Tag)) )
03917 return GE_FALSE;
03918
03919 if ( ! geVFile_Write(F, &geBM_Version, sizeof(geBM_Version)) )
03920 return GE_FALSE;
03921
03922 if ( ! geBitmap_WriteInfo(Bmp,F) )
03923 return GE_FALSE;
03924
03925 #ifdef COUNT_HEADER_SIZES
03926 Header_Sizes += 15;
03927 #endif
03928
03929 // the pointer Bmp->Info.Palette serves as boolean : HasPalette
03930 if ( Bmp->Info.Palette )
03931 {
03932 if ( ! geBitmap_Palette_WriteToFile(Bmp->Info.Palette,F) )
03933 return GE_FALSE;
03934 }
03935
03936 if ( Bmp->Info.Format == GE_PIXELFORMAT_WAVELET )
03937 {
03938 geErrorLog_AddString(-1,"Genesis3D 1.0 does not support Wavelet Images",NULL);
03939 }
03940 else
03941 {
03942 for( mip = Bmp->Info.MinimumMip; mip <= Bmp->Info.MaximumMip; mip++ )
03943 {
03944
03945 // write out all the interesting mips :
03946 // the first one, and then mips which are not just
03947 // sub-samples of the first (eg. that have been user-set)
03948
03949 if ( (mip == Bmp->Info.MinimumMip || Bmp->Modified[mip]) && Bmp->Data[mip] )
03950 {
03951 uint8 * MipData;
03952 geBoolean MipDataAlloced;
03953 uint32 MipDataLen;
03954
03955 MipDataLen = SHIFT_R_ROUNDUP(Bmp->Info.Width,mip) * SHIFT_R_ROUNDUP(Bmp->Info.Height,mip) *
03956 gePixelFormat_BytesPerPel(Bmp->Info.Format);
03957
03958 if ( Bmp->Info.Stride == Bmp->Info.Width )
03959 {
03960 MipData = Bmp->Data[mip];
03961 MipDataAlloced = GE_FALSE;
03962 }
03963 else
03964 {
03965 int w,h,s,y;
03966 uint8 * fptr,*tptr;
03967
03968 if ( ! (MipData = geRam_Allocate(MipDataLen) ) )
03969 {
03970 geErrorLog_AddString(-1,"Bitmap_WriteToFile : Ram_Alloc failed!",NULL);
03971 return GE_FALSE;
03972 }
03973
03974 MipDataAlloced = GE_TRUE;
03975
03976 s = SHIFT_R_ROUNDUP(Bmp->Info.Stride,mip)* gePixelFormat_BytesPerPel(Bmp->Info.Format);
03977 w = SHIFT_R_ROUNDUP(Bmp->Info.Width,mip) * gePixelFormat_BytesPerPel(Bmp->Info.Format);
03978 h = SHIFT_R_ROUNDUP(Bmp->Info.Height,mip);
03979
03980 fptr = Bmp->Data[mip];
03981 tptr = MipData;
03982 for(y=h;y--;)
03983 {
03984 memcpy(tptr,fptr,w);
03985 fptr += s;
03986 tptr += w;
03987 }
03988 }
03989
03990 assert( mip <= MIP_MASK );
03991 flags = mip;
03992 #ifdef DO_LZ
03993 flags |= MIP_FLAG_COMPRESSED;
03994 #endif
03995
03996 if ( ! geVFile_Write(F, &flags, sizeof(flags)) )
03997 return GE_FALSE;
03998
03999 #ifdef DO_LZ
04000 {
04001 geVFile * LzF;
04002 LzF = geVFile_OpenNewSystem(F,GE_VFILE_TYPE_LZ,NULL,NULL,GE_VFILE_OPEN_CREATE);
04003 if ( ! LzF )
04004 {
04005 if ( MipDataAlloced )
04006 geRam_Free(MipData);
04007 geErrorLog_AddString(-1,"Bitmap_WriteToFile : LZ File Open failed",NULL);
04008 return GE_FALSE;
04009 }
04010
04011 if ( ! geVFile_Write(LzF, MipData, MipDataLen ) )
04012 return GE_FALSE;
04013
04014 if ( ! geVFile_Close(LzF) )
04015 {
04016 if ( MipDataAlloced )
04017 geRam_Free(MipData);
04018 geErrorLog_AddString(-1,"Bitmap_WriteToFile : LZ File Close failed",NULL);
04019 return GE_FALSE;
04020 }
04021 }
04022 #else
04023 if ( ! geVFile_Write(F, MipData, MipDataLen ) )
04024 return GE_FALSE;
04025 #endif
04026
04027 if ( MipDataAlloced )
04028 geRam_Free(MipData);
04029 }
04030 }
04031
04032 // mip > MaximumMip signals End-Of-Mips
04033
04034 flags = MIP_MASK;
04035 if ( ! geVFile_Write(F, &flags, sizeof(flags)) )
04036 return GE_FALSE;
04037 }
04038
04039 // the pointer Bmp->Alpha serves as boolean : HasAlpha
04040
04041 if( Bmp->Alpha )
04042 {
04043 if ( ! geBitmap_WriteToFile(Bmp->Alpha,F) )
04044 return GE_FALSE;
04045 }
04046
04047 return GE_TRUE;
04048 }
|
|
||||||||||||||||
|
Definition at line 3705 of file bitmap.c. References GE_FALSE, GE_VFILE_OPEN_CREATE, GE_VFILE_TYPE_DOS, geBitmap_WriteToFile(), geBoolean, GENESISAPI, GENESISCC, geVFile_Close(), geVFile_Open(), geVFile_OpenNewSystem(), and NULL.
03706 {
03707 geVFile * File;
03708 geBoolean Ret;
03709
03710 if ( BaseFS )
03711 {
03712 File = geVFile_Open((geVFile *)BaseFS, Name, GE_VFILE_OPEN_CREATE);
03713 }
03714 else
03715 {
03716 File = geVFile_OpenNewSystem(NULL,GE_VFILE_TYPE_DOS,Name,NULL,GE_VFILE_OPEN_CREATE);
03717 }
03718
03719 if ( ! File )
03720 return GE_FALSE;
03721
03722 Ret = geBitmap_WriteToFile(Bmp,File);
03723
03724 geVFile_Close(File);
03725
03726 return Ret;
03727 }
|
1.3.2