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 18-03-2003, 12:55
Craig Tucker
Guest
 
Posts: n/a
Default Importing Files...

Hey All,
What is the best way to import a file into a boundingbox, but resize the boundingbox width/height to conform to the image being imported. IOW, want to import a portrait jpg picture into a square bounding box and don't want the jpg stretched. I currently import images into boundingboxes using the following code, but the image being imported is already sized correspondingly...

s.GetBoundingBox ldLogoX, ldLogoY, ldLogoSX, ldLogoSY
mPage.ActiveLayer.Import lcLogo

Thanks Much,
Craig...
Reply With Quote
  #2  
Old 18-03-2003, 18:14
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Importing Files...

Craig,

I don't see how your code stretches the imported file to fit into the bounding box of a shape. As far as I can tell, you just get the bounding box of a shape and then import a file. Maybe later you move it somehow, but that's not visible from the code you provided.

Anyway, my guess is that you want to import an image and place it inside a shape so that the imported graphics is no larger than the shape itself.

That's very easily done with Shape.SetBoundingBox method which can stretch shapes while keeping proprtions.

Here is a simple code that imports a file and places it "inside" the selected rectangle:

Code:
Public Sub ImportAndFit()
    Dim x As Double, y As Double
    Dim sx As Double, sy As Double
    
    If ActiveShape Is Nothing Then
        MsgBox "Please select a container object first", vbCritical
        Exit Sub
    End If
    ActiveShape.GetBoundingBox x, y, sx, sy
    ActiveLayer.Import "C:\Temp\1.gif"
    If ActiveShape Is Nothing Then
        MsgBox "Nothing imported", vbCritical
        Exit Sub
    End If
    ActiveShape.SetBoundingBox x, y, sx, sy, True, cdrCenter
End Sub
As you see, it's very easy to do. SetBoundingBox is quite smart. Here True means "keep original shape proportions while fitting it into the new bounding box". The last cdrCenter specifies that the shape should be centered both horizontally and vertically within the specified bounding box. You can use any of the other reference point constants such as cdrTopLeft or cdrMiddleRight.

I hope this is what you wanted.
Reply With Quote
  #3  
Old 18-03-2003, 19:40
Craig Tucker
Guest
 
Posts: n/a
Default

Alex,
That was dead on target! As you guessed, this is exactly what I needed...
I had stopped at:
.ActiveSelection.SetBoundingBox ldLogoX, ldLogoY, ldLogoSX, ldLogoSY
and didn't know about the additional features.
Again, Thanks so much for the help!
Craig...
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
Importing only 1st page from a multipage CDR mecanomaniaco CorelDRAW/Corel DESIGNER VBA 3 28-02-2005 17:21
files import graphicdesigner CorelDRAW/Corel DESIGNER VBA 11 19-11-2004 23:56
Coreldraw and importing Excell files GoodLook General 0 24-08-2004 04:49
Thumbnailer Issue with EPS files vallentin Macros/Add-ons 2 16-03-2004 10:04
Corel 10 file conversion script doesn't convert files Kevin CorelDRAW CS 0 13-04-2003 20:28


All times are GMT -5. The time now is 17:24.


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