Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1066763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:03:50+00:00 2026-05-16T20:03:50+00:00

template<class Container> void BlitSurface::ExtractFrames(Container & output, int frame_width, int frame_height, int frames_per_row, int frames_per_column,

  • 0
template<class Container>
void BlitSurface::ExtractFrames(Container & output, int frame_width, int frame_height,
                                         int frames_per_row, int frames_per_column,
                                         bool padding) const
{
    SDL_Surface ** temp_surf = SDL_Ex_ExtractFrames(_surface, frame_width, frame_height, frames_per_row, frames_per_column, padding);

    int surface_count = frames_per_row * frames_per_column;

    output.resize(surface_count);
    Container::iterator iter = output.begin();

    for(int i=0; i<surface_count; ++i, ++iter)
        iter->_surface = temp_surf[i];

    delete [] temp_surf;
}

I have this function splits an image up into frames and stores them into a container of images. How would I modify it to take an iterator instead of a container, and insert the elements at that point?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:03:51+00:00Added an answer on May 16, 2026 at 8:03 pm

    Use back_inserter:

    template<typename OutputIterator>
    void BlitSurface::ExtractFrames(OutputIterator it, int frame_width, int frame_height,
                                             int frames_per_row, int frames_per_column,
                                             bool padding) const
    {
        /* ... other lines unchanged ...*/
        for(int i=0; i<surface_count; ++i) {
            // "BlitSurface()" sets other members to zero. Alternatively you
            // can use boost::value_initialized for that. 
            BlitSurface bs = BlitSurface();
            bs._surface = temp_surf[i];
            *it++ = bs;
        }
        delete [] temp_surf;
    }
    

    Then call it like

    ExtractFrames(std::back_inserter(container), ...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do something like this: template<template<int d, class> class container, int dim
I have a templated container class that looks something like this: template <class ItemType>
Hey there, I'm writing a template container class and for the past few hours
Say i have a templated class template<class T> class A; template<> class A<int> {
We have a structure like below: template<size_t size> class Container{ public: char characters[size]; };
I wrote this simple class that provides buffering for general output operation: template <typename
The following code compiles properly. #include <string> template <typename T, typename U> class Container
Given the following template: template<class T> class Container { private: boost::function<T> f; }; ...
I'm trying to define base class, which contains typedef's only. template<typename T> class A
ExpressionEngine template code: <div class=container_16> <div class=grid_16> {if {segment_1} == home} {embed=include/title title=welcome} {if:elseif

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.