Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New System.Drawing.Bitmap problem...

Status
Not open for further replies.

corchard

Programmer
Jul 3, 2002
23
0
0
CA
"
Code:
BC30519: Overload resolution failed because no accessible 'New' can be called without a narrowing conversion
" referring to the line "
Code:
Dim tb as New System.Drawing.Bitmap(iwid, iHt, PixelFormat.Format24BPPRGB)
" below.

If I replace the variable: iwid with a physical integer like 35, it works! Of course this is not an option given the dynamic requirements of this variable.

Code:
sub Make_Thumbnail()
	'load the source if it is photo 1 and make a thumbnail
	Dim iwid 'the width of the thumbnail
	Dim unit = GraphicsUnit.Pixel ' Set a unit of measurement as pixel, could have used Inch, Point, etc

	if(System.IO.File.Exists("C:\myfolder\test_1.jpg")) = true then 
		Dim ti as System.Drawing.Image
		ti = System.Drawing.Image.FromFile("C:\myfolder\test_1.jpg")
		const iHt = 35 'the height of all thumnails/icons
		iwid = (cInt((iHt * 100) / (ti.height)))
		iwid = (cInt(((iwid * ti.width) / 100)))
		if not iwid > 0 then 			
			iwid = (cInt(iHt + 10))
		end if
		' create a new bitmap that will be the end result
		Dim tb as New System.Drawing.Bitmap(iwid, iHt, PixelFormat.Format24BPPRGB)

		' create a graphics object to work with
		Dim tg as Graphics = Graphics.FromImage(tb)

		' blank the image
		tg.Clear(Color.Blue) 

		'# crop and resize!

		' Draw image using the Pixel unit
		' set above
		tg.DrawImage(ti,new Rectangle(0,0,iwid,iHt),new Rectangle(0,0,ti.width,ti.height),unit)
		ti.Dispose()

		'delete the old thumbnail if available
		if(System.IO.File.Exists("C:\myfolder\test_i.jpg")) = true then 
			System.IO.File.Delete("C:\myfolder\test_i.jpg") 
		end if
		' save the thumbnail to the server
		tb.Save("C:\myfolder\test_i.jpg", ImageFormat.JPEG)
		' tidy up
		tb.Dispose()
		tg.Dispose()
	end if	
end sub

Any help on this would be Super!

Chris
"Illegitimis non carborundum"
(don't let the b@st@rds get you down)
 
Found the problem ...well fixed it, by changing:

Code:
Dim tb as New System.Drawing.Bitmap(iwid, iHt, PixelFormat.Format24BPPRGB)

to:

Code:
Dim tb as New System.Drawing.Bitmap(cInt(iwid), cInt(iHt), PixelFormat.Format24BPPRGB)

Go Figure :p "Illegitimis non carborundum"
(don't let the b@st@rds get you down)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top