Click here to Skip to main content
15,890,438 members
Home / Discussions / Graphics
   

Graphics

 
AnswerRe: draw and select object Pin
Mark Salsbery1-Aug-07 7:59
Mark Salsbery1-Aug-07 7:59 
GeneralRe: draw and select object Pin
mehdi00161-Aug-07 11:02
mehdi00161-Aug-07 11:02 
GeneralRe: draw and select object Pin
Mark Salsbery1-Aug-07 11:33
Mark Salsbery1-Aug-07 11:33 
GeneralRe: draw and select object Pin
mehdi00162-Aug-07 1:05
mehdi00162-Aug-07 1:05 
GeneralRe: draw and select object Pin
Mark Salsbery2-Aug-07 6:22
Mark Salsbery2-Aug-07 6:22 
GeneralRe: draw and select object Pin
Force Code2-Aug-07 5:41
Force Code2-Aug-07 5:41 
GeneralRe: draw and select object Pin
Mark Salsbery2-Aug-07 6:09
Mark Salsbery2-Aug-07 6:09 
AnswerRe: draw and select object Pin
codeII2-Aug-07 6:40
codeII2-Aug-07 6:40 
here is another approach

the first thing you need to do is make a stack
which supports all the graphics you are using:

MyGraphicsStack;
MyGraphicsStack.add( line, rect, color, ... ); <- user draws a line
MyGraphicsStack.add( circle, rect, color, ..., fill ); <- user draws ..
.
.
(or better, make objects and inherit from the same base class)

Now when the user clicks, you create a white temporary bitmap
with the same dimensions as the user is drawing on.
the next thing is drawing your stack ( in the correct order )
on this temporary bitmap. For each item you are drawing,
ignore the color in the GraphicsStack but use instead:
(COLORREF)index_Of_Current_Object_In_MyStack.
(index casting to a color)
for filled objects: use this color for the fill/and the border color.

Then transform your mouse coordinates where the user clicked,
to bitmap coordinates. And for this coordination obtain the
bitmap pixel color.
When you cast the pixel color back it will be the index of the object
kept in your stack, ( or white in case user pressed the bitmap )

UINT nInd = (COLORREF)getpixel(..)
if ( nInd < MyGraphicsStack.Size( ) )
{
MyGraphicsStack[ nInd ] //<-- here it is
}

in this way you have always the topmost object even when
objects are drawn over each other. You also distinct
objects which are filled or not.
( depending on the bit depth of the bitmap you are creating
you are limited in the number of items you can draw,
in that case you could work with more bitmaps,
for a normal 24 bits bitmap you can keep 16777216 - 1 objects
1 = bitmap itself )

remark:
Because Gdi+ plus can ignore drawing objects you are drawing
outside the region of the dc, you can also create a small bitmap
(I think 16x16 is the minimum?) and when drawing to this bitmap
correct for the offset ( the bitmap coordinates the user selected )
in this way that the centre pixel of your small bitmap is the
pixel you are interested in.

well have fun!
Questionbenefit of Map File in Visual C++ ??? Pin
Miss_ Petrovna31-Jul-07 23:25
Miss_ Petrovna31-Jul-07 23:25 
AnswerRe: benefit of Map File in Visual C++ ??? Pin
Luc Pattyn1-Aug-07 8:35
sitebuilderLuc Pattyn1-Aug-07 8:35 
Generalthank U Luc Pattyn Pin
Miss_ Petrovna1-Aug-07 22:58
Miss_ Petrovna1-Aug-07 22:58 
GeneralRe: thank U Luc Pattyn Pin
Luc Pattyn1-Aug-07 23:20
sitebuilderLuc Pattyn1-Aug-07 23:20 
GeneralRe: thank U Luc Pattyn Pin
Miss_ Petrovna4-Aug-07 3:48
Miss_ Petrovna4-Aug-07 3:48 
QuestionAdd water Mark to a video Pin
Jats_4ru31-Jul-07 20:20
Jats_4ru31-Jul-07 20:20 
AnswerRe: Add water Mark to a video Pin
jk chan7-Aug-07 22:01
jk chan7-Aug-07 22:01 
Questioncamera opengl Pin
zqueezy31-Jul-07 15:08
zqueezy31-Jul-07 15:08 
QuestionAnoone tell me how to crack MAYA Unlimite v8 Pin
sonarat30-Jul-07 2:27
sonarat30-Jul-07 2:27 
AnswerRe: Anoone tell me how to crack MAYA Unlimite v8 Pin
Dave Kreskowiak30-Jul-07 10:56
mveDave Kreskowiak30-Jul-07 10:56 
AnswerRe: Anoone tell me how to crack MAYA Unlimite v8 Pin
Pete O'Hanlon2-Aug-07 10:49
mvePete O'Hanlon2-Aug-07 10:49 
QuestionFake webcam? Pin
m0sand29-Jul-07 5:24
m0sand29-Jul-07 5:24 
QuestionHELP:: OpenGL code bugs Pin
sagetarian26-Jul-07 23:56
sagetarian26-Jul-07 23:56 
AnswerRe: HELP:: OpenGL code bugs Pin
Dave Kreskowiak27-Jul-07 11:30
mveDave Kreskowiak27-Jul-07 11:30 
GeneralRe: HELP:: OpenGL code bugs Pin
sagetarian30-Jul-07 5:26
sagetarian30-Jul-07 5:26 
GeneralRe: HELP:: OpenGL code bugs Pin
El Corazon30-Jul-07 10:31
El Corazon30-Jul-07 10:31 
GeneralRe: HELP:: OpenGL code bugs Pin
sagetarian31-Jul-07 6:53
sagetarian31-Jul-07 6:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.