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

Shane Powell shanep at ...2481...
Fri Apr 15 16:23:47 CEST 2011


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Mag-0.0.1.tar.gz
Type: application/x-gzip
Size: 129814 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20110416/594a67b3/attachment.bin>


More information about the User mailing list