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.
dkaip
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Wed Jan 20, 2010 1:15 pm

Place of image ...

Postby dkaip » Tue Jun 19, 2018 7:06 am

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: 2638
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Place of image ...

Postby ONEEYEMAN » Tue Jun 19, 2018 3:34 pm

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

Thank you.

dkaip
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Postby dkaip » Tue Jun 19, 2018 5:58 pm

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: 2638
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Place of image ...

Postby ONEEYEMAN » Tue Jun 19, 2018 6:48 pm

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

Thank you.

dkaip
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Postby dkaip » Wed Jun 20, 2018 5:09 am

No, GetSizer()->FitInside(this); is the last line in function.

dkaip
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Postby dkaip » Wed Jun 20, 2018 6:50 am

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: 12613
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Place of image ...

Postby doublemax » Thu Jun 21, 2018 6:53 am

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
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Postby dkaip » Thu Jun 21, 2018 6:57 am

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: 12613
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Place of image ...

Postby doublemax » Thu Jun 21, 2018 7:13 am

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
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Wed Jan 20, 2010 1:15 pm

Re: Place of image ...

Postby dkaip » Thu Jun 21, 2018 7:12 pm

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


Return to “C++ Development”

Who is online

Users browsing this forum: Google [Bot], rudolfninja and 10 guests