Add graphicsutil package

This commit is contained in:
Hajime Hoshi 2018-03-02 12:34:56 +09:00
parent d4112004b0
commit 247cd6e1c3
3 changed files with 5 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import (
"github.com/hajimehoshi/ebiten/internal/affine" "github.com/hajimehoshi/ebiten/internal/affine"
"github.com/hajimehoshi/ebiten/internal/graphics" "github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/graphicsutil"
"github.com/hajimehoshi/ebiten/internal/opengl" "github.com/hajimehoshi/ebiten/internal/opengl"
"github.com/hajimehoshi/ebiten/internal/restorable" "github.com/hajimehoshi/ebiten/internal/restorable"
) )
@ -416,7 +417,7 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
size := source.Bounds().Size() size := source.Bounds().Size()
checkSize(size.X, size.Y) checkSize(size.X, size.Y)
width, height := size.X, size.Y width, height := size.X, size.Y
rgbaImg := restorable.CopyImage(source) rgbaImg := graphicsutil.CopyImage(source)
p := make([]byte, 4*width*height) p := make([]byte, 4*width*height)
for j := 0; j < height; j++ { for j := 0; j < height; j++ {
copy(p[j*width*4:(j+1)*width*4], rgbaImg.Pix[j*rgbaImg.Stride:]) copy(p[j*width*4:(j+1)*width*4], rgbaImg.Pix[j*rgbaImg.Stride:])

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package restorable package graphicsutil
import ( import (
"image" "image"

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package restorable_test package graphicsutil_test
import ( import (
"image" "image"
@ -20,7 +20,7 @@ import (
"image/color/palette" "image/color/palette"
"testing" "testing"
. "github.com/hajimehoshi/ebiten/internal/restorable" . "github.com/hajimehoshi/ebiten/internal/graphicsutil"
) )
func TestCopyImage(t *testing.T) { func TestCopyImage(t *testing.T) {