OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Replacing bitmap color mode (http://forum.oberonplace.com/showthread.php?t=1644)

xenio 23-07-2006 15:17

Replacing bitmap color mode
There is a way to change the color model of all the bitmap in a document, with a script or a different way?
I prepare the page with cmyk bitmap anyone on is powerclip, sometime I need to export in gray PDF and the conversion in grayscale is very bad.
So I have to convert manually all the bitmap mode to grayscale using the icc profile and then export to pdf.

I try to use the 'find' tool (find all bitmap) but this does not search inside the Powerclip.
Any Idea?

xenio 24-07-2006 10:45

At least, I did it by myself, I am not a coder, but with some cut and paste some trial and error here it is the macro:
Change all the bitmap mode to grayscale (PowerClipped bitmaps too).

Any better code are welcome.


Sub ChangeMode()

Dim s As Shape, sp As Shape
Dim pwc As PowerClip
Dim ChangeCountPowerClip As Integer
Dim ChangeCount As Integer

ChangeCountPowerClip = 0
ChangeCount = 0

For Each s In ActiveDocument.ActivePage.Shapes
    Set pwc = Nothing
    Set pwc = s.PowerClip
    If Not pwc Is Nothing Then
        For Each sp In pwc.Shapes
            If sp.Type = cdrBitmapShape Then
                If sp.Bitmap.Mode <> cdrGrayscaleImage Then
                  sp.Bitmap.ConvertTo cdrGrayscaleImage
                  ChangeCountPowerClip = ChangeCountPowerClip + 1
                End If
            End If
        Next sp
    End If
    If s.Type = cdrBitmapShape Then
        If s.Bitmap.Mode <> cdrGrayscaleImage Then
            s.Bitmap.ConvertTo cdrGrayscaleImage
            ChangeCount = ChangeCount + 1
        End If
    End If

Next s
MsgBox ChangeCount & " Bitmap and " & ChangeCountPowerClip & " inside PowerClip"
End Sub

designhouse 29-04-2007 03:12

Replacing bitmap color mode
make a subroutine & call it from main

I think it is more effective cause your code may not convert images in nested powerclips & my codes can


Private Sub DoReplaceOnShapes(ss As Shapes)

    Dim s As Shape
    For Each s In ss
        Select Case s.Type
            Case cdrBitmapShape
            If s.Bitmap.Mode = cdrRGBColorImage Or cdrDuotoneImage Or cdrLABImage Or cdrPalettedImage Or cdr16ColorsImage Or cdrBlackAndWhiteImage Then
            s.Bitmap.ConvertTo cdrCMYKColorImage
            End If
            End Select
        On Error Resume Next
        If Not s.PowerClip Is Nothing Then DoReplaceOnShapes s.PowerClip.Shapes
    Next s
End Sub


All times are GMT -5. The time now is 20:43.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com