#include <maskfilt.h>
Inheritance diagram for MaskedFilter:
Public Member Functions | |
MaskedFilter () | |
Constructor for an MaskedFilter object. The object should be initialised before use. | |
BOOL | Init () |
Initialise a MaskedFilter object. | |
INT32 | SetTransColour (INT32 NewColour) |
To set a new transparent colour. This has most likely been read in from a GIF file and so needs applying to the bitmap that has just been loaded. | |
INT32 | GetTransColour () |
BOOL | ApplyTransparentColoursToBitmap (KernelBitmap *pExportBitmap=NULL, BitmapExportOptions *pExportOptions=NULL) |
Same as the other flavour of this function. | |
BOOL | ApplyTransparentColoursToBitmap (BITMAPINFOHEADER *pInfoHeader=NULL, BYTE *pBMPBits=NULL, BitmapExportOptions *pExportOptions=NULL, UINT32 YOffset=0, UINT32 StripHeight=0) |
Sets the relavent bits of the bitmap to transparent depending on the given options. | |
virtual UINT32 | GetNumReservedColours () |
If exporting a transparent GIF then reserve 1 palette index for the transpacency mask index. | |
virtual BOOL | ExportSelectionOnly (BOOL MaskedRender=FALSE) |
Determines if the filter wants to export only selected items. In the base filters class version the default action will be to export all objects by default. | |
virtual BOOL | CheckSingleBitmapsOnSpread (Spread *pSpread, BOOL *pSamePalettes, BOOL *pOurBrowserPalette, BOOL *pAllHaveBitmaps, BOOL *pAllWithinCount, UINT32 *pPaletteEntries=NULL) |
This goes through all bitmaps that are on the layers and sees whether they have the same palette and whether the palette is the same as our browser Assumes that each bitmap has been added to a separate layer and that the referenced bitmap in the layer is set to this loaded bitmap. SamePalettes and OurBrowserPalettes are just set for the bitmaps found. | |
Protected Member Functions | |
virtual BOOL | WriteToFile (BOOL End) |
Physically put the bitmap into the disk. | |
virtual OutputDIB * | GetOutputDIB (void) |
virtual void | InvertAlpha (LPBITMAPINFO lpBitmapInfo, LPBYTE lpBits) |
INT32 | FindUnusedColour (LPBITMAPINFO pBMInfo, LPBYTE pBMBits) |
Selects an index to use as the transparent colour from the bitmap data in the output DIB. If an index is unused then this index is used. If there is not an unused index then it is a bit more tricky - the least used colour is made transparent except for 1bpp in which case white becomes transparent. | |
virtual BOOL | SetExportHint (Document *pDoc) |
Overrides base class to set correct hint See Also: BaseBitmapFilter::SetExportHint(). | |
virtual UINT32 | GetHintType (void) |
Protected Attributes | |
UINT32 | Compression |
BOOL | SecondPass |
BOOL | DoingMask |
LPBITMAPINFO | pDestBMInfo |
LPBYTE | pDestBMBytes |
BYTE * | pTempBitmapMask |
UINT32 | CurrentScanline |
INT32 | TransColour |
INT32 | m_BandNumber |
BOOL | m_bSelection |
Private Member Functions | |
CC_DECLARE_DYNAMIC (MaskedFilter) |
Definition at line 187 of file maskfilt.h.
|
Constructor for an MaskedFilter object. The object should be initialised before use.
Definition at line 551 of file maskfilt.cpp. 00552 { 00553 // Used for storing the 8bpp mask until after the second pass is completed 00554 pDestBMInfo = NULL; 00555 pDestBMBytes = NULL; 00556 pTempBitmapMask = NULL; 00557 00558 // Initalise flags 00559 SecondPass = FALSE; 00560 DoingMask = FALSE; 00561 TransColour = -1; // -1 == none, or the transparent colour. 00562 CurrentScanline = 0; 00563 00564 // We don't have any bands to work with yet. 00565 m_BandNumber = 0; 00566 m_bSelection = TRUE; 00567 }
|
|
Sets the relavent bits of the bitmap to transparent depending on the given options.
Definition at line 633 of file maskfilt.cpp. 00635 { 00636 // Check the passed in pointers! 00637 if(!pInfoHeader || !pBMPBits || !pExportOptions) 00638 { 00639 ERROR3("Failed to get valid pointers!"); 00640 return FALSE; 00641 } 00642 00643 // Get the current Export palette and find out how many colours we`re using. 00644 ExtendedPalette* pPal = pExportOptions->GetPalette(); 00645 ERROR3IF(!pPal,"Failed to get a valid palette pointer!"); 00646 00647 INT32 NumOfTranspColours = 0; 00648 INT32 TransColour[256]; 00649 00650 // First get the Transparency index and the check the background status; 00651 INT32 TranspIndex = pExportOptions->GetTransparencyIndex(); 00652 BOOL TransparentBackground = pExportOptions->IsBackgroundTransparent(); 00653 INT32 flag = 0; 00654 00655 if(pPal) 00656 { 00657 // Loop through the colours getting all the one that are marked transparent! 00658 for(INT32 i = 0; i < pPal->NumberOfColours; i++) 00659 { 00660 flag = pPal->Data[i].Flags; 00661 00662 // If we have the backgroung as transparent then we need to make sure we don`t 00663 // include it in the locked colour checking! 00664 if((flag & TRANSPARENT_COLOUR) && !(TransparentBackground && i == TranspIndex)) 00665 TransColour[NumOfTranspColours++] = i; 00666 } 00667 } 00668 00669 // Make sure we`re not doing something stupid! 00670 if(NumOfTranspColours == 0 && !TransparentBackground) 00671 { 00672 ERROR3("What are we tring to do? Durrrr!"); 00673 return FALSE; 00674 } 00675 00676 GRenderBitmap* pMaskedRegion = NULL; 00677 BITMAPINFO* pAlphaInfo = NULL; 00678 BYTE* pAlphaBits = NULL; 00679 00680 // If we want a transparent background then we need to get a 32Bit Alpha BMP! 00681 if(TransparentBackground) 00682 { 00683 // Create a new 32bpp export region with alpha channel info! 00684 // Don't use rendering matrix when exporting BMPs as it uses coordinates as is 00685 Matrix Identity; 00686 FIXED16 Scale(1); 00687 pMaskedRegion = new GRenderBitmap(ClipRect, Identity, Scale, 32, pExportOptions->GetDPI(),FALSE,0,NULL,TRUE); 00688 00689 // If the render region was not created, drop out of this function. 00690 if ( pMaskedRegion == NULL ) 00691 return FALSE; 00692 00693 pMaskedRegion->SetFilter(this); 00694 00695 // Now make sure we set the compression flag to enable transpareny info! 00696 pMaskedRegion->m_DoCompression = TRUE; 00697 pMaskedRegion->SetRenderComplexShapes(TRUE); 00698 RRCaps NewCaps; 00699 NewCaps.CanDoNothing(); 00700 00701 DocView *View = DocView::GetCurrent(); 00702 00703 if (View) 00704 { 00705 // Must force background rendering off as otherwise we might get a partly 00706 // rendered drawing or object if it is complex. 00707 // We have already remembered the entry state so just force it. 00708 ForceBackgroundRedrawOff(View); 00709 00710 // ERROR3IF ( GetBitmapExportOptions()->GetDepth() == -1, 00711 // "Illegal Output Depth in MaskedFilter::RenderTransparencyMask" ); 00712 00713 if (GetBitmapExportOptions()->GetDepth() == 1) 00714 { 00715 // If we are outputting at 1bpp, then we'll force antialiasing off, 00716 // so that Gavin's palette optimisation can detect objects which 00717 // are 'one solid colour' 00718 ForceAntialiasingOff(View); 00719 } 00720 00721 // Attach to the right device. (note no DC) 00722 pMaskedRegion->AttachDevice(View, NULL, pSpread); 00723 } 00724 else 00725 ERROR2(FALSE,"MaskedFilter::RenderTransparencyMask no current view"); 00726 00727 // Export the data from the view into the 1bpp region we have, ensuring rendering 00728 // in strips is off 00729 RenderInStrips = FALSE; 00730 00731 // Now render everything into the new 32Bit Alpha channel region! 00732 if (!ExportRender(pMaskedRegion, TRUE)) 00733 { 00734 // If we have created the export region then delete it so that we free up 00735 // its huge wadges of memory (as its 32bpp deep!). 00736 delete pMaskedRegion; 00737 pMaskedRegion = NULL; 00738 00739 return FALSE; 00740 } 00741 00742 // Now get the info from the 32bit render region 00743 if(!pMaskedRegion->GetBitmapData(&pAlphaInfo,&pAlphaBits)) 00744 { 00745 delete pMaskedRegion; 00746 pMaskedRegion = NULL; 00747 return FALSE; 00748 } 00749 00750 // Check to see if we`ve got Identically dimensioned Bitmaps! 00751 if(pInfoHeader->biWidth != pAlphaInfo->bmiHeader.biWidth || 00752 (YOffset + StripHeight) > (UINT32)pAlphaInfo->bmiHeader.biHeight) 00753 { 00754 delete pMaskedRegion; 00755 pMaskedRegion = NULL; 00756 return FALSE; 00757 } 00758 } 00759 00760 // make a DWORD Pointer to the Alpha Channel bits 00761 DWORD* pAlpha = (DWORD*)pAlphaBits; 00762 00763 // Now get the scanline width for the current bitmap. This will be in multiples of BYTEs 00764 INT32 ScanLineWidth = DIBUtil::ScanlineSize(pInfoHeader->biWidth,pExportOptions->GetDepth()); 00765 INT32 Depth = pExportOptions->GetDepth(); 00766 INT32 PixelsPerByte = 8 / Depth; 00767 00768 // Get the width in pixels for the 32 bit bitmap 00769 INT32 Width32 = pInfoHeader->biWidth / PixelsPerByte; 00770 INT32 SubWidth32 = pInfoHeader->biWidth % PixelsPerByte; 00771 INT32 Scanline = 0; 00772 INT32 StartingPos = 0; 00773 INT32 PixelPos = 0; 00774 INT32 SubPixPos = 0; 00775 INT32 NumOfSubPixels = 0; 00776 INT32 PixelsPerLine = 0; 00777 INT32 i = 0; 00778 INT32 j = 0; 00779 DWORD ByteData = 0x0; 00780 BOOL Padding = FALSE; 00781 UINT32 StripOffset = 0; 00782 UINT32 NoOfLines = StripHeight; 00783 00784 // As 8Bit, 4Bit and 1Bit BMPs are DWORD Alligned, we need to be a little clever in making sure we don`t 00785 // Over run the 32Bit Scanlines! What we need to do is workout exactly how many bytes/bits we really have 00786 // as bitmap! 00787 // As 8Bit BMPs are BYTE Alligned, we don`t need to anything special and just use the bitmap width as is! 00788 // 4Bit is a little more probmatic in that it uses Half Bytes and even worse is 1Bit BMPs! 00789 00790 if(NoOfLines == 0) 00791 NoOfLines = pInfoHeader->biHeight; 00792 00793 if(YOffset > 0) 00794 { 00795 i = ((Width32 * PixelsPerByte) + SubWidth32) * YOffset; 00796 StripOffset = YOffset; 00797 } 00798 00799 // Loop through line by line setting up the transparency information 00800 for (Scanline = StripOffset; (UINT32)Scanline < NoOfLines + StripOffset; Scanline++) 00801 { 00802 StartingPos = Scanline * ScanLineWidth; 00803 PixelsPerLine = StartingPos + Width32; 00804 00805 if(SubWidth32 > 0) 00806 { 00807 PixelsPerLine++; 00808 } 00809 00810 for(PixelPos = StartingPos; PixelPos < PixelsPerLine; PixelPos++) 00811 { 00812 // Get the current Byte of BMP Data at the current Position 00813 // ByteData = _rotr(pBMPBits[PixelPos],8); 00814 ByteData = pBMPBits[PixelPos]>>8 | pBMPBits[PixelPos]<<24; 00815 00816 NumOfSubPixels = PixelsPerByte; 00817 00818 if(PixelPos == StartingPos + Width32) 00819 NumOfSubPixels = SubWidth32; 00820 00821 // Now loop through all the Sub Byte Pixels setting their appropriate values 00822 for(SubPixPos = 0; SubPixPos < PixelsPerByte; SubPixPos++) 00823 { 00824 // ByteData = _rotl(ByteData,Depth); 00825 ByteData = ByteData<<8 | ByteData>>24; 00826 Padding = (SubPixPos >= NumOfSubPixels); 00827 00828 // First check to see if the alpha channel is fully transparent 00829 if((pAlpha && ((pAlpha[i++] & 0xFF000000) >> 24) == 0xFF) || Padding) 00830 { 00831 if(Padding) 00832 i--; 00833 00834 if(Depth == 8) 00835 { 00836 ByteData = TranspIndex; 00837 } 00838 else if(Depth == 4) 00839 { 00840 ByteData &= 0xFFFFFFF0; // Clear the bits we`re going to replace! 00841 ByteData |= (0xF & TranspIndex); // Now AND it with the TranspIndex 00842 } 00843 else if(Depth == 1) 00844 { 00845 ByteData &= 0xFFFFFFFE; // Clear the bits we`re going to replace! 00846 ByteData |= (0x1 & TranspIndex); // Now AND it with the TranspIndex 00847 } 00848 } 00849 else // If it`s not transparent then check the users transparent colours! 00850 { 00851 for(j = 0; j < NumOfTranspColours; j++) 00852 { 00853 if(Depth == 8 && ByteData == (BYTE)TransColour[j]) 00854 { 00855 ByteData = TranspIndex; 00856 break; 00857 } 00858 else if(Depth == 4 && (0xF & ByteData) == (BYTE)TransColour[j]) 00859 { 00860 ByteData &= 0xFFFFFFF0; // Clear the bits we`re going to replace! 00861 ByteData |= (0xF & TranspIndex); // Now AND it with the TranspIndex 00862 break; 00863 } 00864 else if(Depth == 1 && (0x1 & ByteData) == (BYTE)TransColour[j]) 00865 { 00866 ByteData &= 0xFFFFFFFE; // Clear the bits we`re going to replace! 00867 ByteData |= (0x1 & TranspIndex); // Now AND it with the TranspIndex 00868 break; 00869 } 00870 } 00871 } 00872 } 00873 00874 // Replace the current data with the processed version! 00875 pBMPBits[PixelPos] = (BYTE)ByteData; 00876 } 00877 } 00878 00879 // Now delete the masked region if we created one! 00880 if(pMaskedRegion) 00881 { 00882 delete pMaskedRegion; 00883 pMaskedRegion = NULL; 00884 } 00885 return TRUE; 00886 }
|
|
Same as the other flavour of this function.
Definition at line 597 of file maskfilt.cpp. 00598 { 00599 // Check the passed in Variables 00600 if(!pExportBitmap || !pExportOptions) 00601 { 00602 ERROR3("Failed to get valid pointers!"); 00603 return FALSE; 00604 } 00605 00606 // Now get the info and data from the passed in Bitmap 00607 BITMAPINFOHEADER* pInfoHeader = pExportBitmap->GetBitmapInfoHeader(); 00608 BYTE* pBMPBits = pExportBitmap->GetBitmapBits(); 00609 00610 // Call the second version of this function 00611 return ApplyTransparentColoursToBitmap(pInfoHeader,pBMPBits,pExportOptions); 00612 }
|
|
|
|
This goes through all bitmaps that are on the layers and sees whether they have the same palette and whether the palette is the same as our browser Assumes that each bitmap has been added to a separate layer and that the referenced bitmap in the layer is set to this loaded bitmap. SamePalettes and OurBrowserPalettes are just set for the bitmaps found.
Definition at line 1106 of file maskfilt.cpp. 01112 { 01113 ERROR2IF ( pSpread == NULL,FALSE,"CheckSingleBitmapsOnSpread pSpread = NULL" ); 01114 ERROR2IF ( pSamePalettes == NULL || 01115 pOurBrowserPalette == NULL || 01116 pAllHaveBitmaps == NULL, 01117 FALSE, "CheckSingleBitmapsOnSpread bad params!" ); 01118 01119 // Walk through the layers looking at the referenced bitmaps, which are the newly added 01120 // bitmaps. 01121 BOOL SamePalettes = TRUE; 01122 BOOL OurBrowserPalette = TRUE; 01123 BOOL AllHaveBitmaps = TRUE; 01124 BOOL BitmapFound = FALSE; 01125 BOOL AllWithinCount = TRUE; 01126 UINT32 Bpp = 0; 01127 01128 KernelBitmap * pBitmap = NULL; 01129 LPLOGPALETTE pBrowserPalette = NULL; 01130 LPRGBQUAD pPreviousPalette = NULL; 01131 UINT32 PreviousPalEntries = 0; 01132 UINT32 ReqNumberOfPalEntries = 0; 01133 UINT32 MaxPaletteEntries = 0; 01134 if (pPaletteEntries != NULL) 01135 ReqNumberOfPalEntries = *pPaletteEntries; 01136 01137 Layer * pLayer = pSpread->FindFirstLayer(); 01138 while (pLayer != NULL) 01139 { 01140 // Only check pseudo frame layers as these are what the grab frame ops use 01141 if (!pLayer->IsBackground() && !pLayer->IsGuide() && 01142 !pLayer->IsPageBackground()) 01143 { 01144 pBitmap = pLayer->GetReferencedBitmap(); 01145 if (pBitmap) 01146 { 01147 BitmapFound = TRUE; 01148 01149 Bpp = pBitmap->GetBPP(); 01150 if (Bpp <= 8) 01151 { 01152 UINT32 PalEntries = pBitmap->GetNumPaletteEntries(); 01153 // Note this as a possible new maximum number of entries 01154 if (PalEntries > MaxPaletteEntries) 01155 MaxPaletteEntries = PalEntries; 01156 LPRGBQUAD pPalette = pBitmap->GetPaletteForBitmap(); 01157 if (PalEntries > ReqNumberOfPalEntries) 01158 AllWithinCount = FALSE; 01159 01160 // Obviously, browser palettes can only happen on 8bpp bitmaps 01161 if (Bpp == 8 && OurBrowserPalette) 01162 { 01163 // If we haven't done so already, allocate ourselves a browser 01164 // palette. 01165 // This MUST be the same one that we will use on saving 01166 if (pBrowserPalette == NULL) 01167 { 01168 UINT32 PaletteSize = UINT32( pow( 2.0, double(Bpp) ) ); 01169 pBrowserPalette = DIBUtil::AllocateLogPalette(PaletteSize); 01170 if (pBrowserPalette != NULL) 01171 { 01172 // Now force it into a browser compatible state 01173 BOOL AvoidSystemColours = TRUE; 01174 PaletteManager::MakePaletteBrowserCompatible 01175 ( pBrowserPalette, AvoidSystemColours ); 01176 } 01177 } 01178 01179 INT32 TransColour = -1; 01180 pBitmap->GetTransparencyIndex(&TransColour); 01181 01182 if (pBrowserPalette != NULL && OurBrowserPalette) 01183 OurBrowserPalette = pBitmap->ArePalettesTheSame(pBrowserPalette,TransColour); 01184 else 01185 OurBrowserPalette = FALSE; 01186 } 01187 else if (SamePalettes) 01188 { 01189 OurBrowserPalette = FALSE; 01190 01191 // If we have two palettes to compare then do so, 01192 // Otherwise wait for a second palette 01193 if (pPalette && pPreviousPalette) 01194 { 01195 if (PalEntries == PreviousPalEntries) 01196 { 01197 for (UINT32 i = 0; (i < PalEntries) && SamePalettes; i++) 01198 { 01199 if ( pPalette[i].rgbRed != pPreviousPalette[i].rgbRed && 01200 pPalette[i].rgbGreen != pPreviousPalette[i].rgbGreen && 01201 pPalette[i].rgbBlue != pPreviousPalette[i].rgbBlue 01202 ) 01203 SamePalettes = FALSE; 01204 } 01205 } 01206 else 01207 SamePalettes = FALSE; 01208 } 01209 } 01210 else 01211 OurBrowserPalette = FALSE; 01212 } 01213 else 01214 { 01215 OurBrowserPalette = FALSE; 01216 SamePalettes = FALSE; 01217 } 01218 01219 // Note this bitmap as the previous one 01220 PreviousPalEntries = pBitmap->GetNumPaletteEntries(); 01221 pPreviousPalette = pBitmap->GetPaletteForBitmap(); 01222 } 01223 else 01224 AllHaveBitmaps = FALSE; 01225 } 01226 01227 pLayer = pLayer->FindNextLayer(); 01228 } 01229 01230 // If no bitmaps have been found then we must reset the palette flags as otherwise 01231 // they will be showing the wrong value. 01232 if (!BitmapFound) 01233 { 01234 SamePalettes = FALSE; 01235 OurBrowserPalette = FALSE; 01236 AllWithinCount = FALSE; 01237 } 01238 01239 // return the results in the variables supplied 01240 if (pSamePalettes) 01241 *pSamePalettes = SamePalettes; 01242 if (pOurBrowserPalette) 01243 *pOurBrowserPalette = OurBrowserPalette; 01244 if (pAllHaveBitmaps) 01245 *pAllHaveBitmaps = AllHaveBitmaps; 01246 if (pAllWithinCount) 01247 *pAllWithinCount = AllWithinCount; 01248 01249 if (pPaletteEntries) 01250 { 01251 // If we have the same palette on all bitmaps then set the number of palette 01252 // entries to be correct, otherwise set to the maximum found. 01253 if (SamePalettes) 01254 *pPaletteEntries = PreviousPalEntries; 01255 else 01256 *pPaletteEntries = MaxPaletteEntries; 01257 } 01258 01259 // Free up our allocated browser palette 01260 if (pBrowserPalette != NULL) 01261 CCFree(pBrowserPalette); 01262 01263 return TRUE; 01264 }
|
|
Determines if the filter wants to export only selected items. In the base filters class version the default action will be to export all objects by default.
Reimplemented from Filter. Reimplemented in GrabFrameFilter. Definition at line 1066 of file maskfilt.cpp. 01067 { 01068 // we dont do any of this secondpass / GeneratingOptimisedPalette bussiness anymore 01069 // that is all done in a nice tight loop. So we would never want to just render the selection 01070 // otherwise the background sometimes disappears which would be odd. sjk 3/1/01 01071 MaskedFilterExportOptions* pMaskedOptions = (MaskedFilterExportOptions*)GetBitmapExportOptions(); 01072 ERROR2IF(pMaskedOptions == NULL, FALSE, "NULL Args"); 01073 ERROR3IF(!pMaskedOptions->IS_KIND_OF(MaskedFilterExportOptions), "pMaskedOptions isn't"); 01074 return (pMaskedOptions->GetSelectionType() == SELECTION && 01075 ((pMaskedOptions->IsBackgroundTransparent() && MaskedRender) 01076 || pMaskedOptions->GetDepth() == 32)); 01077 }
|
|
Selects an index to use as the transparent colour from the bitmap data in the output DIB. If an index is unused then this index is used. If there is not an unused index then it is a bit more tricky - the least used colour is made transparent except for 1bpp in which case white becomes transparent.
Definition at line 1308 of file maskfilt.cpp. 01309 { 01310 ERROR2IF(pBMBits==NULL || pBMInfo==NULL, -1, "NULL bitmap pointer"); 01311 01312 // Count the colours used in the bitmap 01313 UINT32* pResults = NULL; 01314 BOOL ok = DIBUtil::CountColoursUsed(pBMInfo, pBMBits, &pResults); 01315 ERROR2IF(pResults == NULL, -1, "NULL results array"); 01316 01317 INT32 TransIndex = -1; 01318 if (ok) 01319 TransIndex = DIBUtil::FindLeastUsedColour(pBMInfo, pResults); 01320 01321 CCFree(pResults); 01322 pResults = NULL; 01323 01324 return TransIndex; 01325 }
|
|
Reimplemented in TI_GIFFilter. Definition at line 245 of file maskfilt.h. 00245 { return(HINTTYPE_BAD); }
|
|
If exporting a transparent GIF then reserve 1 palette index for the transpacency mask index.
Reimplemented from BaseBitmapFilter. Definition at line 1279 of file maskfilt.cpp. 01280 { 01281 MaskedFilterExportOptions* pMaskedOptions = (MaskedFilterExportOptions*)GetBitmapExportOptions(); 01282 ERROR2IF(pMaskedOptions == NULL, FALSE, "NULL Member"); 01283 ERROR3IF(!pMaskedOptions->IS_KIND_OF(MaskedFilterExportOptions), "pMaskedOptions isn't"); 01284 01285 if (pMaskedOptions->WantTransparent()) 01286 return 1; 01287 else 01288 return 0; 01289 }
|
|
Reimplemented in TI_GIFFilter, ImageMagickFilter, and PNGFilter. Definition at line 222 of file maskfilt.h. 00222 { return NULL; }
|
|
Definition at line 197 of file maskfilt.h. 00197 { return TransColour; }
|
|
Initialise a MaskedFilter object.
Reimplemented from BaseBitmapFilter. Reimplemented in PreviewFilterGIF, PreviewFilterPNG, TI_GIFFilter, ImageMagickFilter, and PNGFilter. Definition at line 579 of file maskfilt.cpp. 00580 { 00581 return MaskedFilterExportOptions::Declare(); 00582 }
|
|
Reimplemented in ImageMagickFilter, and PNGFilter. Definition at line 225 of file maskfilt.h.
|
|
Overrides base class to set correct hint See Also: BaseBitmapFilter::SetExportHint().
Reimplemented from BaseBitmapFilter. Definition at line 1338 of file maskfilt.cpp. 01339 { 01340 if (pDoc != NULL && !IsPreviewBitmap) 01341 { 01342 ExportHint* pHint = pDoc->GetExportHint(); 01343 ERROR3IF(pHint == NULL, "NULL ExportHint"); 01344 01345 BitmapExportOptions* pBaseOptions = GetBitmapExportOptions(); 01346 ERROR3IF(pBaseOptions == NULL, "NULL Options"); 01347 01348 if (pHint != NULL && pBaseOptions != NULL) 01349 { 01350 ERROR3IF(!(pBaseOptions->IsKindOf(CC_RUNTIME_CLASS(MaskedFilterExportOptions))), "Wrong options type"); 01351 MaskedFilterExportOptions* pOptions = (MaskedFilterExportOptions*) pBaseOptions; 01352 01353 // If derived class doesn't wat to hint then exit 01354 if (GetHintType() == HINTTYPE_BAD) 01355 return(TRUE); 01356 01357 pHint->SetType(GetHintType()); 01358 pHint->SetWidth(GetPixelWidth()); 01359 pHint->SetHeight(GetPixelHeight()); 01360 pHint->SetBPP(pOptions->GetDepth()); 01361 01362 String_256 Opts; 01363 Opts._MakeMsg(_T("D#1%ld"), pOptions->GetDither()); 01364 01365 if (pOptions->GetDepth() <= 8) 01366 { 01367 String_256 TempStr; 01368 TempStr._MakeMsg(_T(" P#1%ld N#2%ld"), 01369 pOptions->GetPalette(), 01370 pOptions->GetNumColsInPalette()); 01371 Opts += TempStr; 01372 01373 if (pOptions->GetUseSystemColours()) 01374 Opts += _T(" S"); 01375 } 01376 01377 if (pOptions->WantTransparent()) 01378 Opts += _T(" T"); 01379 if (pOptions->WantInterlaced()) 01380 Opts += _T(" I"); 01381 01382 pHint->SetOptionsString(Opts); 01383 } 01384 } 01385 return(TRUE); 01386 }
|
|
To set a new transparent colour. This has most likely been read in from a GIF file and so needs applying to the bitmap that has just been loaded.
Definition at line 1039 of file maskfilt.cpp. 01040 { 01041 INT32 OldTransColour = TransColour; 01042 TransColour = NewColour; 01043 01044 return OldTransColour; 01045 }
|
|
Physically put the bitmap into the disk.
This function was originally duplicated in the TI_GIFFilter, and PNG_Filter, but have now been rolled into a single function. This makes maintenance easier, and should reduce code size. Reimplemented from BaseBitmapFilter. Reimplemented in MakeBitmapFilter. Definition at line 907 of file maskfilt.cpp. 00908 { 00909 #ifdef DO_EXPORT 00910 00911 if(GeneratingOptimisedPalette()) 00912 return TRUE; // No need to output anything. 00913 00914 BitmapExportOptions* pBMPOptions = GetBitmapExportOptions(); 00915 OutputDIB* pDestDIB = GetOutputDIB(); 00916 00917 LPBITMAPINFO lpBitmapInfo = NULL; 00918 LPBYTE lpBitmapBits = NULL; 00919 LPLOGPALETTE lpPalette = NULL; 00920 00921 // Make sure that valid values have been set. 00922 ERROR2IF ( pBMPOptions == NULL, FALSE, "NULL Args" ); 00923 ERROR2IF ( pDestDIB == NULL, FALSE, "No DIB available for export" ); 00924 00925 // Check that the class variable for the spread to use has been set up in. 00926 ERROR2IF(pSpread==NULL,FALSE,"PNGFilter::WriteToFile spread pointer is null"); 00927 00928 // Increment the band number. 00929 m_BandNumber++; 00930 00931 // Get the bitmap data from the Render Region 00932 ExportRegion->GetBitmapData(&lpBitmapInfo, &lpBitmapBits); 00933 00934 ERROR3IF(lpBitmapBits == NULL, "Bitmap has no data in BMPFilter::WriteDataToFile"); 00935 00936 if (lpBitmapInfo == NULL || lpBitmapBits == NULL) 00937 return FALSE; 00938 00939 // Now call InvertAlpha() - This is for the PNG Derived filter 00940 InvertAlpha(lpBitmapInfo,lpBitmapBits); 00941 00942 // Lets write out a suitable header. 00943 // As we write it in one big chunk (currently), its easy 00944 if (!WrittenHeader) 00945 { 00946 WrittenHeader = TRUE; 00947 00948 LPBITMAPINFO lpInfo = lpBitmapInfo; 00949 ERROR2IF(lpInfo==NULL,FALSE,"PNGFilter::WriteToFile null export region bitmap"); 00950 if (pTempBitmapMask != NULL) 00951 { 00952 TRACEUSER( "SimonK", _T("pTempBitmapMask was not deleted when it should have been")); 00953 CCFree(pTempBitmapMask); 00954 pTempBitmapMask = NULL; 00955 } 00956 00957 // ERROR3IF ( pBMPOptions->GetDepth() == -1, "Illegal OutputDepth in PNGFilter::WriteToFile" ); 00958 00959 // First, get the size of the bitmap we are going to export not just the simple 00960 // lpInfo->bmiHeader.biHeight as this might just be the height of the first 00961 // strip to be exported. With the width we can use the old method. 00962 // const UINT32 OutputWidth = lpInfo->bmiHeader.biWidth; 00963 const UINT32 OutputHeight = (INT32)ExportRegion->GetFullRegionHeight(); 00964 00965 if ( pBMPOptions->GetDepth () == 8 || 00966 pBMPOptions->GetDepth () == 4 || 00967 pBMPOptions->GetDepth () == 1 ) 00968 { 00969 // SMFIX 00970 // get the logical palette from the options 00971 lpPalette = pBMPOptions->GetLogicalPalette(); 00972 } 00973 00974 // Start up the export process and prepare all the bitmaps and files ready for 00975 // the actual bitmap data 00976 // For transparent export we will do this twice so flag which pass we are on. 00977 if ( !pDestDIB->StartFile ( &lpInfo->bmiHeader, 00978 lpPalette, 00979 pBMPOptions->GetDepth(), // actual file depth 00980 Compression, // interlace/transparency 00981 OutputHeight, // all of it 00982 SizeOfExport, // progress bar size 00983 pBMPOptions->GetDither() ) ) // dithering to use 00984 { 00985 return FALSE; 00986 } 00987 } 00988 00989 // Now lets write out our block. This actually just copies the data into our 00990 // destination bitmap. Need to do this so cope with interlacing and transparency 00991 const UINT32 StripHeight = lpBitmapInfo->bmiHeader.biHeight; 00992 00993 // SMFIX - Mark Howitt 00994 // New code to make sure we export with transparency correctly! 00995 INT32 InputBPP = 32; 00996 BYTE* pActualBits = lpBitmapBits; 00997 if ( !pDestDIB->WriteBlock ( 0, // Ypos 00998 StripHeight, // height of this strip 00999 pActualBits, // pointer to actual bitmap data 01000 InputBPP, // input bpp 01001 ProgressOffset ) ) // value to add to progress update 01002 { 01003 return FALSE; 01004 } 01005 01006 // if we have a transparency and we are 8 bit or less 01007 if (pBMPOptions->GetTransparencyIndex() > -1 && pBMPOptions->GetDepth() <= 8) 01008 { 01009 // Now send the intermediate bitmap to the ApplyTransparentColoursToBitmap function 01010 if(!ApplyTransparentColoursToBitmap(&pDestDIB->GetDestBitmapInfo()->bmiHeader,pDestDIB->GetDestBitmapBits(),pBMPOptions,m__StripStart,StripHeight)) 01011 { 01012 ERROR2(FALSE,"Failed to create an intermediate bitmap pointer!"); 01013 } 01014 } 01015 01016 // Add in the height of the strip that we have just exported to the progress offset value 01017 ProgressOffset += StripHeight; 01018 m__StripStart += StripHeight; 01019 #endif 01020 return TRUE; 01021 }
|
|
Definition at line 229 of file maskfilt.h. |
|
Definition at line 238 of file maskfilt.h. |
|
Definition at line 232 of file maskfilt.h. |
|
Definition at line 247 of file maskfilt.h. |
|
Definition at line 249 of file maskfilt.h. |
|
Definition at line 236 of file maskfilt.h. |
|
Definition at line 235 of file maskfilt.h. |
|
Definition at line 237 of file maskfilt.h. |
|
Definition at line 231 of file maskfilt.h. |
|
Definition at line 240 of file maskfilt.h. |