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 10-10-2004, 22:19
lees
Guest
 
Posts: n/a
Default how to use getpixel() to get the Image color?

I want to get the Image's color by using getpixel().but the vba didn't has PictureBox.And the Image didn't has Hdc method!
so ,
Declare Function GetPixelx Lib "gdi32" Alias "GetPixel" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long

can't reach the hDC of the Image.

so can u hello me?

thx!
Reply With Quote
  #2  
Old 10-10-2004, 23:43
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: how to use getpixel() to get the Image color?

lees,

What picture are you talking about? You can use my UI Extension library to do some interesting things, including loading a BMP file into memory and getting pixel colors... And a good thing is that this DLL is installed with CorelDRAW 11 and 12, so you don't have to include it with your macros.

Here is a VBA interface to the DLL's functions:

Code:
Option Explicit

Public Declare Function BeginImage& Lib "scprtl20.dll" (ByVal x&, ByVal y&, ByVal Color&)
Public Declare Sub EndImage Lib "scprtl20.dll" (ByVal Path$)
Public Declare Sub PutPixel Lib "scprtl20.dll" Alias "PutPixelEx" (ByVal x&, ByVal y&, ByVal Color&)
Public Declare Function GetPixel& Lib "scprtl20.dll" Alias "GetPixelEx" (ByVal x&, ByVal y&)

Public Declare Sub ImageLine Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal Width&, ByVal Color&)
Public Declare Sub ImageLineEx Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&)
Public Declare Sub ImageRectangle Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal Width&, ByVal Color&)
Public Declare Sub ImageRectangleEx Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&)
Public Declare Sub ImageFillRect Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal Color&)
Public Declare Sub ImageFillRectEx Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&)
Public Declare Sub ImageRoundRect Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal d1&, ByVal d2&, ByVal Width&, ByVal Color&)
Public Declare Sub ImageRoundRectEx Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal d1&, ByVal d2&)
Public Declare Sub ImageFillRoundRect Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal d1&, ByVal d2&, ByVal Color&)
Public Declare Sub ImageFillRoundRectEx Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal d1&, ByVal d2&)
Public Declare Sub ImageEllipse Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal Width&, ByVal Color&)
Public Declare Sub ImageEllipseEx Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&)
Public Declare Sub ImageFillEllipse Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal Color&)
Public Declare Sub ImageFillEllipseEx Lib "scprtl20.dll" (ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&)
Public Declare Sub ImagePolyline Lib "scprtl20.dll" (ByVal n&, ByRef pt&, ByVal w&, ByVal Color&)
Public Declare Sub ImagePolylineEx Lib "scprtl20.dll" (ByVal n&, ByRef pt&)
Public Declare Sub ImageFillPolyline Lib "scprtl20.dll" (ByVal n&, ByRef pt&, ByVal Color&)
Public Declare Sub ImageFillPolylineEx Lib "scprtl20.dll" (ByVal n&, ByRef pt&)

Public Declare Sub ImageMoveTo Lib "scprtl20.dll" (ByVal x&, ByVal y&)
Public Declare Sub ImageLineTo Lib "scprtl20.dll" (ByVal x&, ByVal y&, ByVal Width&, ByVal Color&)
Public Declare Sub ImageLineToEx Lib "scprtl20.dll" (ByVal x&, ByVal y&)
Public Declare Sub ImageBezierTo Lib "scprtl20.dll" (ByVal cx1&, ByVal cy1&, ByVal cx2&, ByVal cy2&, ByVal x&, ByVal y&, ByVal Width&, ByVal Color&)
Public Declare Sub ImageBezierToEx Lib "scprtl20.dll" (ByVal cx1&, ByVal cy1&, ByVal cx2&, ByVal cy2&, ByVal x&, ByVal y&)
Public Declare Function ImageCloseShape Lib "scprtl20.dll" () As Long

Public Declare Function ImageBeginPath Lib "scprtl20.dll" () As Boolean
Public Declare Function ImageEndPath Lib "scprtl20.dll" () As Boolean
Public Declare Function ImageAbortPath Lib "scprtl20.dll" () As Boolean
Public Declare Function ImageSavePath Lib "scprtl20.dll" () As Boolean
Public Declare Function ImageLoadPath Lib "scprtl20.dll" () As Boolean

Public Declare Sub ImageFillPath Lib "scprtl20.dll" (ByVal Color&)
Public Declare Function ImageFillPathEx Lib "scprtl20.dll" () As Long
Public Declare Sub ImageStrokePath Lib "scprtl20.dll" (ByVal Width&, ByVal Color&)
Public Declare Function ImageStrokePathEx Lib "scprtl20.dll" () As Long

Public Declare Function ImageSelectClipPath Lib "scprtl20.dll" (ByVal Mode&) As Boolean
Public Declare Function ImageGetClipBox Lib "scprtl20.dll" (ByRef x1&, ByRef y1&, ByRef x2&, ByRef y2&) As Boolean
Public Declare Function ImageResetClipRegion Lib "scprtl20.dll" () As Long

Public Declare Sub ImageTextOut Lib "scprtl20.dll" (ByVal Text$, ByVal x&, ByVal y&, ByVal Face$, ByVal PointSize&, ByVal Weight&, _
                    ByVal Italic&, ByVal Underline&, ByVal StrikeOut&, ByVal Color&)
Public Declare Sub ImageGetTextSize Lib "scprtl20.dll" (ByVal Text$, ByRef x&, ByRef y&, ByVal Face$, ByVal PointSize&, ByVal Weight&, _
                    ByVal Italic&, ByVal Underline&, ByVal StrikeOut&)

Public Declare Sub ImageSolidFill Lib "scprtl20.dll" (ByVal Color&)
Public Declare Sub ImageHatchFill Lib "scprtl20.dll" (ByVal Style&, ByVal Color&)
Public Declare Sub ImageBitmapFill Lib "scprtl20.dll" (ByVal Path$)
Public Declare Sub ImageOutline Lib "scprtl20.dll" (ByVal Style&, ByVal Width&, ByVal Color&)

Public Declare Function ImageSetROP2 Lib "scprtl20.dll" (ByVal DrawMode&) As Long

Public Declare Sub ImageDrawBitmap Lib "scprtl20.dll" (ByVal Path$, ByVal x&, ByVal y&)
Public Declare Sub ImageDrawIcon Lib "scprtl20.dll" (ByVal Path$, ByVal x&, ByVal y&, ByVal sx&, ByVal sy&)
Public Declare Sub ImageDrawEMF Lib "scprtl20.dll" (ByVal Path$, ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal KeepAspect&)
Public Declare Sub ImageDrawWMF Lib "scprtl20.dll" (ByVal Path$, ByVal x1&, ByVal y1&, ByVal x2&, ByVal y2&, ByVal KeepAspect&)
Public Declare Function ImageLoadImageList Lib "scprtl20.dll" (ByVal Path$, ByVal cx&, ByVal TRANSPARENT&, ByVal Color&) As Boolean
Public Declare Function ImageDrawImageList Lib "scprtl20.dll" (ByVal Index&, ByVal x&, ByVal y&) As Boolean

' Hatch Styles
Public Const HS_HORIZONTAL = 0            ' -----
Public Const HS_VERTICAL = 1              ' |||||
Public Const HS_FDIAGONAL = 2             ' \\\\\
Public Const HS_BDIAGONAL = 3             ' /////
Public Const HS_CROSS = 4                 ' +++++
Public Const HS_DIAGCROSS = 5             ' xxxxx

' Pen Styles
Public Const PS_SOLID = 0
Public Const PS_DASH = 1                  ' -------
Public Const PS_DOT = 2                   ' .......
Public Const PS_DASHDOT = 3               ' _._._._
Public Const PS_DASHDOTDOT = 4            ' _.._.._

Public Const R2_BLACK = 1             '  0
Public Const R2_NOTMERGEPEN = 2       ' DPon
Public Const R2_MASKNOTPEN = 3        ' DPna
Public Const R2_NOTCOPYPEN = 4        ' PN
Public Const R2_MASKPENNOT = 5        ' PDna
Public Const R2_NOT = 6               ' Dn
Public Const R2_XORPEN = 7            ' DPx
Public Const R2_NOTMASKPEN = 8        ' DPan
Public Const R2_MASKPEN = 9           ' DPa
Public Const R2_NOTXORPEN = 10        ' DPxn
Public Const R2_NOP = 11              ' D
Public Const R2_MERGENOTPEN = 12      ' DPno
Public Const R2_COPYPEN = 13          ' P
Public Const R2_MERGEPENNOT = 14      ' PDno
Public Const R2_MERGEPEN = 15         ' DPo
Public Const R2_WHITE = 16            '  1

Public Const RGN_AND = 1
Public Const RGN_OR = 2
Public Const RGN_XOR = 3
Public Const RGN_DIFF = 4
Public Const RGN_COPY = 5

Last edited by Alex; 11-04-2007 at 12:59.
Reply With Quote
  #3  
Old 11-10-2004, 04:48
lees
Guest
 
Posts: n/a
Default

I know you mean.and thank you very much!

but the
Public Declare Function GetPixel& Lib "scprtl20.dll" Alias "GetPixelEx" (ByVal x&, ByVal y&amp

should be use in the
Public Declare Function BeginImage& Lib "scprtl20.dll" (ByVal x&, ByVal y&, ByVal Color&amp

Public Declare Sub EndImage Lib "scprtl20.dll" (ByVal Path$)

which should creat a new bitmap.
if I want to load a picture such as "c:\a.bmp"

and get the (20,5)' color .how can I do?

thx!
Reply With Quote
  #4  
Old 11-10-2004, 10:25
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

You need to use BeginImage, then ImageDrawBitmap to paint a BMP file on the "canvas" and then you can use GetPixel to get the pixel color... I hope this makes sense.
Reply With Quote
  #5  
Old 11-10-2004, 22:11
lees
Guest
 
Posts: n/a
Default

thx!!!!
but how can I know if the beginImage' width and height just the bmp' width and height?
and how can i get the *.jpg file?
thx!
Reply With Quote
  #6  
Old 12-10-2004, 07:21
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

In this case, you'd better use Photo-Paint and it's GetPixelColor...
Reply With Quote
  #7  
Old 17-10-2004, 00:13
lees
Guest
 
Posts: n/a
Default

thank you very much!
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
Image picture location RVogel CorelDRAW/Corel DESIGNER VBA 0 31-03-2005 12:05
Wish to Convert Named Colors to Shape Color D_Green CorelDRAW/Corel DESIGNER VBA 1 12-09-2004 11:08
Apply Outline - Scale with Image geopig CorelDRAW/Corel DESIGNER VBA 4 06-05-2004 07:23
Population of Image Box ddonnahoe CorelDRAW/Corel DESIGNER VBA 10 10-02-2004 13:20
color replacer - some ideas Zuk Macros/Add-ons 0 29-04-2003 03:09


All times are GMT -5. The time now is 19:46.


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