Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to image handling #7

Closed
wants to merge 1 commit into from
Closed

Changes to image handling #7

wants to merge 1 commit into from

Conversation

scottfurry
Copy link
Contributor

@scottfurry scottfurry commented May 21, 2016

gu* is used as an indicator of guayadeque object. Change the references of guImage and guBitmap to indicate they are functions and not objects.

Too often there is code that will accept a wxBitmap but is given a wxBitmap converted to a wxImage, which is internally converted to a wxBitmap. This is mostly seen in context menus and wxBitmapButton type classes. Creation of these objects is given a wxBitmap directly.

Array index of image data (see src/Images.cpp) is dangerously dependent on its position in the array.
Changes made to explicitly associate imaged data to its index value. (use std::map)

guRoundButton and guRoundToggleButton classes were not touched. Classes take wxImage as a parameter but use wxBitmap internally.

Code clean up to fix some indentations

@anonbeat
Copy link
Owner

Why the namespace guNS_Image ?

@scottfurry
Copy link
Contributor Author

gu has been used to indicate objects or classes.
guNS_ is indicating this is namspace (not an object or class ).

@anonbeat
Copy link
Owner

anonbeat commented May 22, 2016

Also the NewFromPNGData does exactly the same I was doing when returning a bitmap. Build an wxImage and construct a wxBitmap from it

wxBitmap wxBitmapHelpers::NewFromPNGData(const void* data, size_t size)
{
    wxBitmap bitmap;

#ifdef wxHAS_PNG_LOAD
    wxMemoryInputStream is(data, size);
    wxImage image(is, wxBITMAP_TYPE_PNG);
    if ( image.IsOk() )
        bitmap = wxBitmap(image);
#endif // wxHAS_PNG_LOAD

    return bitmap;
}

@anonbeat
Copy link
Owner

Other thing is using std::map. It makes live easier to the developer but worse to the cpu. I prefer things worse for the developer and more easy for the CPU.

this is the [] operator for the std map source code

       operator[](const key_type& __k)
       {
            // concept requirements
          __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)

         iterator __i = lower_bound(__k);
        // __i->first is greater than or equivalent to __k.
        if (__i == end() || key_comp()(__k, (*__i).first))
           __i = insert(__i, value_type(__k, mapped_type()));
         return (*__i).second;
     }

Insane to access an element in an array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants