OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 19-04-2010, 17:43
Keefster
Guest
 
Posts: n/a
Default Copy from DRAW to PP

During runtime, I need to send a bitmap to PhotoPaint, alter it, and send it back to DRAW. I am at a loss as how to do this. Please help.
Reply With Quote
  #2  
Old 19-04-2010, 18:01
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default CorelDRAW to PP

Not directly but you could use an API call or Send Key to send the bitmap as explained here by Alex: "Edit bitmap" from Script or via COM

Another option would be to copy and paste, but I would not suggest this.

A third would be to Export the bitmap to a temp file from Draw, open it in PP, make your changes and save, then import back into DRAW replacing the current bitmap. Personally this is the approach I would use.

-Shelby
Reply With Quote
  #3  
Old 19-04-2010, 18:09
Keefster
Guest
 
Posts: n/a
Default

Thanks Shelby!

I like the export option too.

Now I just need to figure out how to import the file into PP, alter it using the channel mixer, and export it for use in Draw. Any suggestions/hints?
Reply With Quote
  #4  
Old 20-04-2010, 01:05
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default CorelDRAW to PP

Hopefully this will get you started, it is far from perfect, no error handlers so things could go wrong. :-)

First you need to add a reference to PHOTO-PAINT in CorelDRAW. Do this by opening the VBA editor (ALT-F11) clicking Tools | References | And check the Corel - Corel PHOTO-PAINT Type Library, then click ok.

Second make sure you have a folder named c:\temp or change this in the code to a folder the already exists.

Now you should be able to use the code.
Code:
Sub FromDrawToPhotoPaintAndBackAgain()
    Dim appDraw As New CorelDRAW.Application
    Dim appPaint As New PHOTOPAINT.Application
    Dim filter As CorelDRAW.ExportFilter
    Dim docPP As PHOTOPAINT.Document
    Dim docDRAW As CorelDRAW.Document
    Dim sOrigBitmap As CorelDRAW.Shape, sNewBitmap As CorelDRAW.Shape
    Dim x As Double, y As Double
    
    If appDraw.ActiveShape.Type = cdrBitmapShape Then
        Set sOrigBitmap = appDraw.ActiveShape
        Set docDRAW = appDraw.ActiveDocument
        sOrigBitmap.GetPosition x, y
        Set filter = docDRAW.ExportBitmap("C:\temp\~temp.jpg", cdrJPEG, cdrSelection, cdrRGBColorImage)
        filter.Finish
        Set filter = Nothing
        
        Set docPP = appPaint.OpenDocument("c:\temp\~temp.jpg")
        appPaint.CorelScript.BitmapEffect "Channel Mixer", Chr(7) + "ChannelMixerEffect InputColourModel+AD0-1,OutputChannel+AD0-0,PreviewOutputOnly+AD0-0,Level1+AD0-160+AHw-0+AHw-0+AHw-0,Level2+AD0--140+AHw-100+AHw-0+AHw-0,Level3+AD0-160+AHw-0+AHw-100+AHw-0,Level4+AD0-0+AHw-0+AHw-0+AHw-100"
        docPP.SaveAs("c:\temp\~temp.jpg", cdrJPEG).Finish
        docDRAW.ActiveLayer.Import "c:\temp\~temp.jpg"
        Set sNewBitmap = appDraw.ActiveSelection
        sNewBitmap.SetPosition x, y
        sOrigBitmap.Delete
        Kill "c:\temp\~temp.jpg"
    End If
End Sub
The code simply exports the currently selected bitmap, adds a Channel Effect in PHOTO-PAINT then sends it back to CorelDRAW deleting the original.

-Shelby
Reply With Quote
  #5  
Old 20-04-2010, 12:11
Keefster
Guest
 
Posts: n/a
Default

Damn Shelby...you rock! I have been struggling with this for some time!
I havent written anything involving PP and am finding it hard to get a toe-hold on the PP side.

Thank you so much!
Reply With Quote
  #6  
Old 20-04-2010, 12:55
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,778
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default PhotoPaint

For the PhotoPaint side you still need to use a lot of Script. What I normally do is use the Recorder in PhotoPaint to record the script command, then copy and paste it into my VBA project. That is how I got all those crazy settings for the Channel Mixer, cheated! Recorded it. ;-)

-Shelby
Reply With Quote
  #7  
Old 25-04-2010, 16:02
SteveDude SteveDude is offline
Senior Member
 
Join Date: Dec 2005
Location: Salina, Kansas USA
Posts: 149
Default You Do Rock!

Shelby,

I have been doing this the hard way in C++ by creating and embedding it as OLE object. Using a similar approach getting into other programs such as PhotoShop.

Your way is much easier.

...you just keep getting better and better. Never cease to amaze me and it has been fun watching you grow.

Steve
Reply With Quote
  #8  
Old 25-04-2010, 17:43
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

You both kick ass.

I'd still love to do this with trace 12 and draw x4,x5.
I know its tough, no vba for trace12.

-John
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I copy an Envelope? RobC CorelDRAW/Corel DESIGNER VBA 13 11-04-2008 13:33
Copy Protect PDF ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 07-08-2006 07:25
COPY DropShadow igor___ CorelDRAW/Corel DESIGNER VBA 1 28-03-2006 20:44
Copy Layer Mike83 Corel Photo-Paint VBA 0 09-02-2006 08:41
Copy Properties > all xombie CorelDRAW/Corel DESIGNER VBA 2 18-04-2005 14:50


All times are GMT -5. The time now is 06:23.


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