Place of image ...

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Place of image ...

Post by dkaip »

Hello. In code bellow(is from diff-pdf from TT solution) how i can know the exactrly points of image inside the sizer?
Thank's
Jim

Code: Select all

    if ( new_w != m_orig_image.GetWidth() ||
            new_h != m_orig_image.GetHeight() )
    {
        scaled =
            m_orig_image.Scale
            (
                new_w,
                new_h,
                // we don't need HQ filtering when upscaling
                m_zoom_factor < 1.0
                ? wxIMAGE_QUALITY_HIGH
                : wxIMAGE_QUALITY_NORMAL
            );
        new_bitmap=wxBitmap(scaled);
    }
    else
    {
        new_bitmap=wxBitmap(m_orig_image);
    }

    GetSizer()->FitInside(this);
Last edited by dkaip on Thu Jun 21, 2018 6:52 am, edited 1 time in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Place of image ...

Post by ONEEYEMAN »

Hi,
Why do you need it?
Did you try wxBitmap::GetPosition()?

Thank you.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Post by dkaip »

Every time that a bitmap fits inside a wxSizer, depending of bitmap size and screen size, fits with different ways.
If you want to put at image shapes that are objects, not embedding inside, the shapes depends from current image zoom factor.
So to make a coordinate convert you must know the exactly place and other settings of image inside a wxSizer.
So i must know the exact place of image.
GetPosition() gives point (0,0) that i wrong for scaled bitmap.
Thank's
Jim
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Place of image ...

Post by ONEEYEMAN »

Hi,
Are you calling Layout() at the end of that function?

Thank you.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Post by dkaip »

No, GetSizer()->FitInside(this); is the last line in function.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Post by dkaip »

Suppose in code that i am study, i want to put scaled bitmap at certain place, so with this way i will know the exact coordinates of image,but how i must put inside in a pos?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Place of image ...

Post by doublemax »

If you're using sizers, you don't have control over the exact position. What exactly are you trying to do? And why?
Use the source, Luke!
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Post by dkaip »

Hi.
To put a shape in a certain place, and in zoom operation to see at place as viewing before.
Just for study ...
Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Place of image ...

Post by doublemax »

Which control are you using to display the image?
What's the overall layout?
Are there any other controls in the same sizer structure? If yes, it's pretty much impossible to do.

If this shall also work then zooming, you'd need to put the image inside a wxScrolledWindow, so that you can control its relative position without affecting any other control.
Use the source, Luke!
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Post by dkaip »

The code is part of diff-pdf. Sizer has only the bitmap.

Code: Select all

// ctor
    wxBitmap dummyBitmap(16, 16);
    m_content = new wxStaticBitmap(this, wxID_ANY, dummyBitmap);

    wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
    sizer->Add(m_content, wxSizerFlags(1).Expand());
    SetSizer(sizer);
class BitmapViewer : public wxScrolledWindow
and
class DiffFrame : public wxFrame
private:
BitmapViewer *m_viewer;

Code is very complicate in diff-pdf, and i study and try it how it works.
Thank you
Jim
Post Reply