WayneSpangler

I have the following code:

' Set the color matrix and the image attributes
Dim clrMatrix As New ColorMatrix(Ary)
Dim imgAttributes As New ImageAttributes
imgAttributes.SetColorMatrix(clrMatrix)
Dim g As Graphics = Graphics.FromImage(tempBmp)
'================================================================
' This is from MS Help
'Graphics.DrawImage Method (Image, Point[], Rectangle, GraphicsUnit, ImageAttributes)

'================================================================
g.DrawImage(OverlayBmp, New Point(0, 0), SrcData, GraphicsUnit.Pixel, imgAttributes)

The g.DrawImage is underlined with the following message:

"Overload resolution failed because no accessible "DrawImage" can be called with these arguments"

What is in purple above is from MS Help file. Why am I getting this message

I am trying to take a portion of a picture, scale it up and make 50% transparent. If I'm not mistaken I have to use this method to do that.




Re: Visual Basic Express Edition DrawImage Error

nobugz

That DrawImage() overload requires an array of Points, you're passing a single point. Here's a sample program that uses another overload:

Public Class Form1
Private mImage As Image
Private mAlpha As Single = 0.5
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim mx As New Imaging.ColorMatrix
mx.Matrix33 = mAlpha
Dim ia As New Imaging.ImageAttributes
ia.SetColorMatrix(mx)
Dim rc As New Rectangle(0, 0, Panel1.Width, Panel1.Height)
e.Graphics.DrawImage(mImage, rc, 0, 0, mImage.Width, mImage.Height, GraphicsUnit.Pixel, ia)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mImage = Bitmap.FromFile("c:\temp\test.bmp")
End Sub
End Class






Re: Visual Basic Express Edition DrawImage Error

DMan1

Make sure that all of your variables are properly defined types...for example is SrcData a rectangle

Public Sub DrawImage(ByVal image As System.Drawing.Image, ByVal destPoints() As System.Drawing.Point, ByVal srcRect As System.Drawing.Rectangle, ByVal srcUnit As System.Drawing.GraphicsUnit, ByVal imageAttr As System.Drawing.Imaging.ImageAttributes)

Member of: System.Drawing.Graphics

Summary:

Draws the specified portion of the specified System.Drawing.Image object at the specified location.

Parameters:

imageAttr: System.Drawing.Imaging.ImageAttributes object that specifies recoloring and gamma information for the image object.

srcUnit: Member of the System.Drawing.GraphicsUnit enumeration that specifies the units of measure used by the srcRect parameter.

image: System.Drawing.Image object to draw.

destPoints: Array of three System.Drawing.Point structures that define a parallelogram.

srcRect: System.Drawing.Rectangle structure that specifies the portion of the image object to draw.






Re: Visual Basic Express Edition DrawImage Error

WayneSpangler

Thanks guys,

The square brackets ( [] ) should have tipped me off but sometimes I am brain dead.

I have decided to go with the following (I don't get an error):

g.DrawImage(OverlayBmp, DestData, SrcData.X, SrcData.Y, SrcData.Width, SrcData.Height, GraphicsUnit.Pixel, imgAttributes)

Thanks again,

Wayne