[Gambas-user] an "Is this possible question" about images

richard terry rterry at ...1946...
Sat Apr 16 07:27:09 CEST 2011


On Saturday 16 April 2011 10:29:15 Shane Powell wrote:

Hi Shane,

I had an 11MB picture I wanted to magnify (I'll send you an image of this off 
list), with your last code iteration only part of the image was shown, so I 
changed the code in the drawingarea1_draw, to make the whole image show.

However now, the mouse pointer dosn't show what's under it.

?? fixable??

I'll send make the picture where the mouse was so that you can see what the 
mouse was actually pointing at and what showed in the magnified area.

Otherwise, the prototype looks good. We should buff it up and put it into the 
gambas examples!

Regards

richard

> On 16/04/11 08:53, richard terry wrote:
> > On Saturday 16 April 2011 00:23:47 Shane Powell wrote:
> >
> > Thanks heaps to shane, Caveat and all - I'll try a look at all this today
> > and report back.
> >
> > Regards
> >
> > Richard
> >
> >> On 15/04/11 22:58, richard terry wrote:
> >>> On Friday 15 April 2011 17:02:25 richard terry wrote:
> >>> Hi Kevin/List,
> >>>
> >>> I took at quick look at this, but my lame brain never functions with
> >>> basic mathematical problems, I enclose an embryonic code.
> >>>
> >>> This 'sort of' works, theres a drawing area into which I loaded the
> >>> image of a shoulder Xray and then another  on top which will be the
> >>> magnifier. I put a couple of textboxes on it to change some of the
> >>> internal values, but can't seem to figure out the magnification
> >>> factors.
> >>>
> >>> If I click over this it does move around and magnify, albeit not lined
> >>> up properly and sometimes it seems to get lost. It would be nice to
> >>> have this be say a circle, with a border, and be accurate, maybe
> >>> someone can modfy the code to make it work.
> >>>
> >>> Any help appreciated.
> >>>
> >>>> On Friday 15 April 2011 16:15:13 Kevin Fishburne wrote:
> >>>> Thanks, and to  Rolf-Werner Eilert's reply, I'll take a look at these
> >>>> suggestions when I go home.
> >>>>
> >>>> I need a little 'side project' to stave off the bordum of the hum-drum
> >>>> debugging of the main project.
> >>>>
> >>>> Will post back my  sucess or lack therof
> >>>>
> >>>> Regards
> >>>>
> >>>> Richard
> >>>>
> >>>>> On 04/15/2011 12:47 AM, richard terry wrote:
> >>>>>>> Do you need it to look like a fisheye-style lens effect, or just
> >>>>>>> box-zoom an area? If the latter this can be done easily in gb code.
> >>>>>>
> >>>>>> Just the box-zoom .
> >>>>>>
> >>>>>> Any change of you giving me a helping hand? I've not done anything
> >>>>>> much with images or drawing.
> >>>>>>
> >>>>>> I'll mail you a sample png if you want - the purpose here is to
> >>>>>> magnify areas of either skin, xray films or dermatascope images -
> >>>>>> all are images at the end of the day.
> >>>>>>
> >>>>>> Its for our open - source medical records project that Ian and I are
> >>>>>> chuggling slowly along with - not releasable as yet by I'm hoping
> >>>>>> that by the end of 2011 it will be pretty much beta.
> >>>>>
> >>>>> That is very cool. I'm doing a game so I know a little about images
> >>>>> in gb.
> >>>>>
> >>>>> I'm going to assume that you're using Qt or GTK and not SDL or
> >>>>> OpenGL, but correct me if I'm wrong. For those the easiest way to do
> >>>>> graphics is with a DrawingArea control. After creating it on the form
> >>>>> I'd change the Cached property to True so it will automatically
> >>>>> redraw itself if something moves over it.
> >>>>>
> >>>>> You create image variables and load image files into them like this:
> >>>>>
> >>>>> Dim/Public someimage As Image
> >>>>> someimage = Image.Load("FleshEatingVirusNooooo.jpg")
> >>>>>
> >>>>> You write images to the DrawingArea control like this:
> >>>>>
> >>>>> Draw.Begin(DrawingArea1)
> >>>>>      Draw.Image(someimage, X, Y, [Width, Height, SrcX, SrcY,
> >>>>> SrcWidth, SrcHeight])
> >>>>>      ' Add more "Draw.Image" statements here to composite additional
> >>>>> images into the DrawingArea.
> >>>>> Draw.End ' Commits the composition to the DrawingArea so that it may
> >>>>> be seen. May need a "Wait" statement if done repeatedly.
> >>>>>
> >>>>> The [bracketed] parameters are optional. someimage is the source and
> >>>>> the DrawingArea is the target. You can specify a subset of the source
> >>>>> (the area to be zoomed) by playing with SrcX and SrcY (upper-left
> >>>>> corner of source to be drawn) and SrcWidth and SrcHeight (width and
> >>>>> height relative to SrcX and SrcY of source to be drawn). You can
> >>>>> scale the source by playing with Width and Height.
> >>>>>
> >>>>> So that the source image writes to the DrawingArea don't leave a
> >>>>> trail, I'd first draw the main (unzoomed) image to the DrawingArea,
> >>>>> then draw the zoomed area onto that for each "frame" that you draw.
> >>>>> The logic would go something like:
> >>>>>
> >>>>> ' Create your image variables.
> >>>>> ' Load images into your image variables.
> >>>>> Draw.Begin(DrawingAreaControlName)
> >>>>> ' Draw the main image into the DrawingArea.
> >>>>> ' Draw part of the main image into the DrawingArea adjusted by cursor
> >>>>> position, zoom area size and zoom level.
> >>>>> ' Draw text or whatever else you need to into the DrawingArea.
> >>>>> Draw.End
> >>>>>
> >>>>> To draw text, which is really cool, you may do something like this
> >>>>> inside the Draw.Begin/End:
> >>>>>
> >>>>> Draw.Foreground = Color.Black
> >>>>> Draw.Text("Look, it's text on an image with a crappy shadow!!!", X,
> >>>>> Y) Draw.Foreground = Color.White
> >>>>> Draw.Text("Look, it's text on an image with a crappy shadow!!!", X +
> >>>>> 1, Y - 1)
> >>>>>
> >>>>> I don't have any project examples that are simple enough to
> >>>>> demonstrate this, but if you're really having trouble I could put
> >>>>> something together.
> >>>>
> >>>> ----------------------------------------------------------------------
> >>>>-- --- --- Benefiting from Server Virtualization: Beyond Initial
> >>>> Workload Consolidation -- Increasing the use of server virtualization
> >>>> is a top priority.Virtualization can reduce costs, simplify
> >>>> management, and improve application availability and disaster
> >>>> protection. Learn more about boosting the value of server
> >>>> virtualization.
> >>>> http://p.sf.net/sfu/vmware-sfdev2dev
> >>>> _______________________________________________
> >>>> Gambas-user mailing list
> >>>> Gambas-user at lists.sourceforge.net
> >>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>>>
> >>>>
> >>>>
> >>>> ----------------------------------------------------------------------
> >>>>-- ------ Benefiting from Server Virtualization: Beyond Initial
> >>>> Workload Consolidation -- Increasing the use of server virtualization
> >>>> is a top priority.Virtualization can reduce costs, simplify
> >>>> management, and improve application availability and disaster
> >>>> protection. Learn more about boosting the value of server
> >>>> virtualization.
> >>>> http://p.sf.net/sfu/vmware-sfdev2dev
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> Gambas-user mailing list
> >>>> Gambas-user at lists.sourceforge.net
> >>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
> >>
> >> this is how i would do it when the mouse cursor get to the right  or the
> >> bottom of the image it starts to strech but you could just limit the
> >> mouse travel and the rest you could make how you wanted easy i think
> >> hope it helps
> >
> > -------------------------------------------------------------------------
> >----- Benefiting from Server Virtualization: Beyond Initial Workload
> > Consolidation -- Increasing the use of server virtualization is a top
> > priority.Virtualization can reduce costs, simplify management, and
> > improve application availability and disaster protection. Learn more
> > about boosting the value of server virtualization.
> > http://p.sf.net/sfu/vmware-sfdev2dev
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> just some more tinkering
> 
-------------- next part --------------
' Gambas class file
Private mx As Integer
Private my As Integer
Private base As Image
Private magx As Integer = 50
Private magy As Integer = 50
Public Sub _new()

End

Public Sub Form_Open()
base = Image.Load("shoulder.png")
base = Image.Load("1.png")
DrawingArea1.Width = base.Width
DrawingArea1.Height = base.Height
PictureBox1.Picture = Picture.Load("1.png")
End

Public Sub DrawingArea1_MouseMove()

  If Mouse.x + (magx / 2) < base.Width And If Mouse.x - (magx / 2) > 0 
    mx = Mouse.X
  Endif
  
  If Mouse.y + (magy / 2) < base.Height And If Mouse.Y - (magy / 2) > 0
    my = Mouse.Y
  Endif
  
  DrawingArea1.Refresh
  DrawingArea2.Refresh
  

End

Public Sub DrawingArea1_Draw()

  Draw.Image(base, 0, 0)
  Draw.Image(Base, 0, 0, DrawingArea1.w, DrawingArea1.H)
   
  

End

Public Sub DrawingArea2_Draw()

  Draw.Image(base, 0, 0, DrawingArea2.Width, DrawingArea2.height, mx - (magx / 2), my - (magy / 2), magx, magy)
  

End

Public Sub Slider1_Change()

  magx = DrawingArea2.Width / Slider1.Value
  magy = DrawingArea2.Height / Slider1.Value
  Label1.Text = "Mag= X" & Slider1.Value
  
End


More information about the User mailing list