Solved

Problem with API FloodFill

Posted on 1998-10-07
5
492 Views
Last Modified: 2007-10-18
I am currently developing a graphic editor which will open and save files in WMF format.  I'm using API function calls to draw GDI objects to WMF format but I am having trouble with FloodFill.  According to my references, each metafile records contain a function with a specified Function Number and the FloodFill's function number is &H419.  All of the API calls I used produced their expected function numbers except for one, the FloodFill for it returned an UNKNOWN FUNCTION with a function number &H548(when I used the ListWMF software to view the metafile records).  What's so funny about it is that you can display the metafile correctly when you play it on screen, but when you play the metafile to the printer, the FloodFill doesn't work.  I have received suggestions to first turn the WMF to bitmap before printing but I don't want this for it causes pixelation.

Can anyone help me find a FloodFill function which will produce the correct Function Number?
0
Comment
Question by:lyka090898
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
&h419 = META_FLOODFILL
&H548 = META_EXTFLOODFILL
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
Comment Utility
Most likely floodfill is not supported by the printer.
Use GetDeviceCaps to find out

Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Public Const RASTERCAPS = 38        
public const RC_FLOODFILL = &h1000

GetDeviceCaps

The GetDeviceCaps function retrieves device-specific information about a specified device.

int GetDeviceCaps(
  HDC hdc,     // device-context handle
  int nIndex   // index of capability to query
);
 


Parameters



hdc

Handle to the device context.

nIndex

Specifies the item to return. This parameter can be one of the following values:
IndexMeaningDRIVERVERSIONThe device driver version.TECHNOLOGYDevice technology. It can be any one of the following values:
ValueMeaningDT_PLOTTERVector plotterDT_RASDISPLAYRaster displayDT_RASPRINTERRaster printerDT_RASCAMERARaster cameraDT_CHARSTREAMCharacter streamDT_METAFILEMetafileDT_DISPFILEDisplay file
If the hdc parameter identifies the device context of an enhanced metafile, the device technology is that of the referenced device as given to the CreateEnhMetaFile function. To determine whether it is an enhanced metafile device context, use the GetObjectType function.HORZSIZEWidth, in millimeters, of the physical screen.VERTSIZEHeight, in millimeters, of the physical screen.HORZRESWidth, in pixels, of the screen.VERTRESHeight, in raster lines, of the screen.LOGPIXELSXNumber of pixels per logical inch along the screen width. In a system with multiple display monitors, this value is the same for all monitors.LOGPIXELSYNumber of pixels per logical inch along the screen height. In a system with multiple display monitors, this value is the same for all monitors.BITSPIXELNumber of adjacent color bits for each pixel.PLANESNumber of color planes.NUMBRUSHESNumber of device-specific brushes.NUMPENSNumber of device-specific pens.NUMFONTSNumber of device-specific fonts.NUMCOLORSNumber of entries in the device's color table, if the device has a color depth of no more than 8 bits per pixel. For devices with greater color depths, -1 is returned.ASPECTXRelative width of a device pixel used for line drawing.ASPECTYRelative height of a device pixel used for line drawing.ASPECTXYDiagonal width of the device pixel used for line drawing.PDEVICESIZEReserved.CLIPCAPSFlag that indicates the clipping capabilities of the device. If the device can clip to a rectangle, it is 1. Otherwise, it is 0.SIZEPALETTENumber of entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with Windows version 3.0 or later.NUMRESERVEDNumber of reserved entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with Windows version 3.0 or later.COLORRESActual color resolution of the device, in bits per pixel. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with Windows version 3.0 or later.PHYSICALWIDTHFor printing devices: the width of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical width value of 5100 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller. PHYSICALHEIGHTFor printing devices: the height of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical height value of 6600 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller. PHYSICALOFFSETXFor printing devices: the distance from the left edge of the physical page to the left edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the leftmost 0.25" of paper, has a horizontal physical offset of 150 device units. PHYSICALOFFSETYFor printing devices: the distance from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the topmost 0.5" of paper, has a vertical physical offset of 300 device units. VREFRESHWindows NT: For display devices: the current vertical refresh rate of the device, in cycles per second (Hz).

A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use Win32 display functions such as ChangeDisplaySettings.

DESKTOPHORZRESWindows NT: Width, in pixels, of the virtual desktop. This value may be larger than HORZRES if the device supports a virtual desktop or multiple displays.DESKTOPVERTRESWindows NT: Height, in pixels, of the virtual desktop. This value may be larger than VERTRES if the device supports a virtual desktop or multiple displays.SCALINGFACTORXScaling factor for the x-axis of the printer.SCALINGFACTORYScaling factor for the y-axis of the printer. BLTALIGNMENTWindows NT: Preferred horizontal drawing alignment, expressed as a multiple of pixels. For best drawing performance, windows should be horizontally aligned to a multiple of this value. A value of zero indicates that the device is accelerated, and any alignment may be used.SHADEBLENDCAPSWindows 98, Windows NT 5.0 and later: Value that indicates the shading and blending capabilities of the device.
SB_CONST_ALPHAHandles the SourceConstantAlpha member of the BLENDFUNCTION structure, which is referenced by the blendFunction parameter of the AlphaBlend function.SB_GRAD_RECTCapable of doing GradientFill rectangles.SB_GRAD_TRICapable of doing GradientFill triangles.SB_NONEDevice does not support any of these capabilities.SB_PIXEL_ALPHACapable of handling per-pixel alpha in AlphaBlend. SB_PREMULT_ALPHACapable of handling premultiplied alpha in AlphaBlend.
RASTERCAPSValue that indicates the raster capabilities of the device, as shown in the following table:
CapabilityMeaningRC_BANDINGRequires banding support.RC_BITBLTCapable of transferring bitmaps.RC_BITMAP64Capable of supporting bitmaps larger than 64K.RC_DI_BITMAPCapable of supporting the SetDIBits and GetDIBits functions.RC_DIBTODEVCapable of supporting the SetDIBitsToDevice function.RC_FLOODFILLCapable of performing flood fills.RC_GDI20_OUTPUTCapable of supporting features of Windows 2.0.RC_PALETTESpecifies a palette-based device.RC_SCALINGCapable of scaling.RC_STRETCHBLTCapable of performing the StretchBlt function.RC_STRETCHDIBCapable of performing the StretchDIBits function.
CURVECAPSValue that indicates the curve capabilities of the device, as shown in the following table:
ValueMeaningCC_NONEDevice does not support curves.CC_CHORDDevice can draw chord arcs.CC_CIRCLESDevice can draw circles.CC_ELLIPSESDevice can draw ellipses.CC_INTERIORSDevice can draw interiors.CC_PIEDevice can draw pie wedges.CC_ROUNDRECTDevice can draw rounded rectangles.CC_STYLEDDevice can draw styled borders.CC_WIDEDevice can draw wide borders.CC_WIDESTYLEDDevice can draw borders that are wide and styled.
LINECAPSValue that indicates the line capabilities of the device, as shown in the following table:
ValueMeaningLC_NONEDevice does not support lines.LC_INTERIORSDevice can draw interiors.LC_MARKERDevice can draw a marker.LC_POLYLINEDevice can draw a polyline.LC_POLYMARKERDevice can draw multiple markers.LC_STYLEDDevice can draw styled lines.LC_WIDEDevice can draw wide lines.LC_WIDESTYLEDDevice can draw lines that are wide and styled.
POLYGONALCAPSValue that indicates the polygon capabilities of the device, as shown in the following table:
ValueMeaningPC_NONEDevice does not support polygons.PC_INTERIORSDevice can draw interiors.PC_POLYGONDevice can draw alternate-fill polygons.PC_RECTANGLEDevice can draw rectangles.PC_SCANLINEDevice can draw a single scanline.PC_STYLEDDevice can draw styled borders.PC_WIDEDevice can draw wide borders.PC_WIDESTYLEDDevice can draw borders that are wide and styled.PC_WINDPOLYGONDevice can draw winding-fill polygons.
TEXTCAPSValue that indicates the text capabilities of the device, as shown in the following table:
ValueMeaningTC_OP_CHARACTERDevice is capable of character output precision.TC_OP_STROKEDevice is capable of stroke output precision.TC_CP_STROKEDevice is capable of stroke clip precision.TC_CR_90Device is capable of 90-degree character rotation.TC_CR_ANYDevice is capable of any character rotation.TC_SF_X_YINDEPDevice can scale independently in the x- and y-directions.TC_SA_DOUBLEDevice is capable of doubled character for scaling.TC_SA_INTEGERDevice uses integer multiples only for character scaling.TC_SA_CONTINDevice uses any multiples for exact character scaling.TC_EA_DOUBLEDevice can draw double-weight characters.TC_IA_ABLEDevice can italicize.TC_UA_ABLEDevice can underline.TC_SO_ABLEDevice can draw strikeouts.TC_RA_ABLEDevice can draw raster fonts.TC_VA_ABLEDevice can draw vector fonts.TC_RESERVEDReserved; must be zero.TC_SCROLLBLTDevice cannot scroll using a bit-block transfer. Note that this meaning may be the opposite of what you expect.




Return Values

The return value specifies the value of the desired item.

Remarks

GetDeviceCaps provides the following six indices in place of printer escapes.

Index for GetDeviceCapsPrinter escape replacedPHYSICALWIDTHGETPHYSPAGESIZEPHYSICALHEIGHTGETPHYSPAGESIZEPHYSICALOFFSETXGETPRINTINGOFFSETPHYSICALOFFSETYGETPHYSICALOFFSETSCALINGFACTORXGETSCALINGFACTORSCALINGFACTORYGETSCALINGFACTOR


Windows CE: Windows CE does not support the following values for the nIndex parameter:

VREFRESH

DESKTOPHORZRES

DESKTOPVERTRES

BLTALIGNMENT

Windows CE version 1.0 does not support the following values for the nIndex parameter:

PHYSICALWIDTH

PHYSICALHEIGHT

PHYSICALOFFSETX

PHYSICALOFFSETY
0
 

Author Comment

by:lyka090898
Comment Utility
Mirkwood,

Thanks for bringing out the GetDeviceCaps function to my attention.  I tried to use it and I found out that the function is not supported by my printer.  Now that I know that my printer doesn't support FloodFill, does this mean that it also doesn't support ExtFloodFill in case I try to use EMF instead of WMF?  And in case I really have to convert to EMF, can you refer some websites where I can get some information regarding the internal structure and format of EMF.  I don't have an idea regarding loading (plus enumerating EMF metarecords) and saving EMF files.

I'm NOT rejecting your answer.  I just need to get more information.  Thanks again for the immediate reply.
0
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
First try to see if it is EMF compliant: DC_EMF_COMPLIANT
Yes, Ext floodfill will not be supported
Try this site
http://www.ora.com/centers/gff/formats/micmeta/index.htm
or Altavista
http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&q=%2Bemr+%2Bmetafile+-abbreviation+-acronym+-acronyms+-glossary



0
 

Author Comment

by:lyka090898
Comment Utility
Mirkwood,

Again I would have to get more info.  First should I use DC_EMF_COMPLIANT with GetDeviceCaps just like how I used it with RC_FLOODFILL?  Second, since you asnwered that my PRINTER will not be able to support ExtFloodFill, then WHAT FIUNCTION CAN I USE TO BE ABLE TO PERFORM FLOODFILL (that can be included as a metafile record for both WMF and EMF) that my printer will be able to support?  Since ExtFloodFill will also not be supported by my printer then maybe it would be useless to convert my WMF files to EMF.  Actually, I was able to device my own FloodFill by using a set polylines but when I tried to play the metafile using a smaller window extension, I can view some gaps or unfilled areas which should have been filled, especially if its bounding object has arcs.

By the way, thanks for the websites you mentioned.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now