Export PNG Paletted (8-bit) optimized Floyd-Steinberg

Hello,

Attached is an image of the export options I want to execute with my macro. This is my function and it's ingnoring the palette options. Anyone who can I help me? Image has to be png, transparent,t 8 bit.

Public Sub Export8Bit(ByVal filepath As String, ByVal filename As String, ByVal selectionRange As ShapeRange, ByVal scaleFactor As Double)
    Dim opt                   As New StructExportOptions
    Dim x                     As Double
    Dim y                     As Double
    Dim pal                   As New StructPaletteOptions

    ActiveDocument.Unit = cdrPixel
    
    opt.AntiAliasingType = cdrNormalAntiAliasing
    opt.ImageType = cdrRGBColorImage
    opt.Overwrite = True
    opt.ResolutionX = 96
    opt.ResolutionY = 96
    opt.Transparent = True
    opt.UseColorProfile = False
    opt.MaintainAspect = True
    
    
    pal.DitherType = cdrDitherFloyd
    pal.NumColors = 128
    pal.PaletteType = cdrPaletteOptimized
    pal.DitherIntensity = 100

    Set selectionRange = DeleteGuidelines(selectionRange)

    selectionRange.CreateSelection
    selectionRange.GetSize x, y
    opt.SizeX = x * scaleFactor
    opt.SizeY = y * scaleFactor

    ActiveDocument.Export filepath & filename & ".png", cdrPNG, cdrSelection, opt, pal
End Sub

Parents
No Data
Reply
  • Hope this helps

    Sub TestProgram()


    Dim filepath As String
    Dim filename As String
    Dim shR As ShapeRange
    Dim ScaleFac As Double
    filepath = "C:\Users\chris\Desktop\Corel Draw VBA Snippets\Test Program\"
    filename = "Test PNG"
    Set shR = ActiveSelectionRange
    ScaleFac = 0.1
    Export8Bit filepath, filename, shR, ScaleFac

    End Sub


    Public Sub Export8Bit(ByVal filepath As String, ByVal filename As String, ByVal selectionRange As ShapeRange, ByVal scaleFactor As Double)


    Dim opt As New StructExportOptions
    Dim x As Double
    Dim y As Double
    Dim pal As New StructPaletteOptions
    Dim flt As ExportFilter


    ActiveDocument.Unit = cdrPixel
    opt.AntiAliasingType = cdrNormalAntiAliasing
    opt.ImageType = cdrPalettedImage
    'opt.ImageType = cdrRGBColorImage
    opt.Transparent = True
    opt.Overwrite = True
    opt.ResolutionX = 96
    opt.ResolutionY = 96
    opt.UseColorProfile = False
    opt.MaintainAspect = True

    pal.DitherType = cdrDitherFloyd
    pal.NumColors = 128
    pal.PaletteType = cdrPaletteOptimized
    pal.DitherIntensity = 100

    'Set selectionRange = DeleteGuidelines(selectionRange) This causes an error, is it a private function?

    selectionRange.CreateSelection
    selectionRange.GetSize x, y
    opt.SizeX = x * scaleFactor
    opt.SizeY = y * scaleFactor

    'ActiveDocument.Export filepath & filename & ".png", cdrPNG, cdrSelection, opt, pal


    'I used the ExportEx method and created a variable flt as ExportFilter
    Set flt = ActiveDocument.ExportEx(filepath & filename & ".png", cdrPNG, cdrSelection, opt, pal)


    'The Finish method completes the export process.
    flt.Finish


    'When you set something it is a good idea to eliminate it from memory when done
    Set flt = Nothing
    End Sub

Children
No Data