boten Active Member Licensed User Longtime User Mar 2, 2012 #1 A large image (say 600x600) is "scaled down" on a panel by factor (say 10) resulting in an image drawn as 60x60 Code: Dim bdz As BitmapDrawable Dim pnl as Panel Dim cvs as Canvas Dim rct as Rect bdz.Initialize(LoadBitmap(File.DirAssets, "anyimage.gif")) bdz.Gravity = Gravity.FILL cvs.Initialize(pnl) rct.Initialize(X0,Y0,X0+60,Y0+60) cvs.DrawDrawable(bdz,rct) This works fine, But now I want to get the color of a pixel at (X,Y) withing the drawn image. doing: Code: Dim bmp As Bitmap bmp=bdz.Bitmap p=bmp.GetPixel(X-X0,Y-Y0) does not work and I need to code it as: Code: Dim bmp As Bitmap bmp=bdz.Bitmap p=bmp.GetPixel(10*(X-X0),10*(Y-Y0)) Basically "translating" the coordinates within the drawn picture to the "bigger" coordinates of the original picture. Is there a way to get the value of a pixel on the screen, REGARDLESS of how or from where it was painted?
A large image (say 600x600) is "scaled down" on a panel by factor (say 10) resulting in an image drawn as 60x60 Code: Dim bdz As BitmapDrawable Dim pnl as Panel Dim cvs as Canvas Dim rct as Rect bdz.Initialize(LoadBitmap(File.DirAssets, "anyimage.gif")) bdz.Gravity = Gravity.FILL cvs.Initialize(pnl) rct.Initialize(X0,Y0,X0+60,Y0+60) cvs.DrawDrawable(bdz,rct) This works fine, But now I want to get the color of a pixel at (X,Y) withing the drawn image. doing: Code: Dim bmp As Bitmap bmp=bdz.Bitmap p=bmp.GetPixel(X-X0,Y-Y0) does not work and I need to code it as: Code: Dim bmp As Bitmap bmp=bdz.Bitmap p=bmp.GetPixel(10*(X-X0),10*(Y-Y0)) Basically "translating" the coordinates within the drawn picture to the "bigger" coordinates of the original picture. Is there a way to get the value of a pixel on the screen, REGARDLESS of how or from where it was painted?
thedesolatesoul Expert Licensed User Longtime User Mar 2, 2012 #2 Well, bdz is the original sized picture because: Code: bdz.Initialize(LoadBitmap(File.DirAssets, "anyimage.gif")) you would probably need to save the canvas bitmap somewhere and release the original sized bitmap. Upvote 0
Well, bdz is the original sized picture because: Code: bdz.Initialize(LoadBitmap(File.DirAssets, "anyimage.gif")) you would probably need to save the canvas bitmap somewhere and release the original sized bitmap.
boten Active Member Licensed User Longtime User Mar 2, 2012 #3 thedesolatesoul said: you would probably need to save the canvas bitmap somewhere .... Click to expand... How? Upvote 0
thedesolatesoul said: you would probably need to save the canvas bitmap somewhere .... Click to expand... How?
thedesolatesoul Expert Licensed User Longtime User Mar 2, 2012 #4 You can do Code: canvas.bitmap.getpixel(X-X0,Y-Y0) or Code: Dim bmp as bitmap bmp = canvas.bitmap p=bmp.GetPixel(X-X0,Y-Y0) Upvote 0
You can do Code: canvas.bitmap.getpixel(X-X0,Y-Y0) or Code: Dim bmp as bitmap bmp = canvas.bitmap p=bmp.GetPixel(X-X0,Y-Y0)