<commit_before>/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.badlogic.gdx.tests;

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.tests.utils.GdxTest;
import com.badlogic.gdx.utils.GdxRuntimeException;

public class TextureDataTest extends GdxTest {
	private SpriteBatch spriteBatch;
	private Sprite sprite;

	public void create () {
		spriteBatch = new SpriteBatch();

		sprite = new Sprite(new Texture(new TextureData() {
			public void load () {
				FileHandle file = Gdx.files.internal("data/raw.bin");
				InputStream input = file.read();
				ByteBuffer buffer = ByteBuffer.allocateDirect((int)file.length());
				buffer.order(ByteOrder.nativeOrder());
				byte[] bytes = new byte[1024];
				try {
					while (true) {
						int length = input.read(bytes);
						if (length == -1) break;
						buffer.put(bytes, 0, length);
					}
				} catch (IOException ex) {
					throw new GdxRuntimeException(ex);
				}
				buffer.flip();
				Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, getWidth(), getHeight(), 0, GL10.GL_RGBA,
					GL10.GL_UNSIGNED_SHORT_4_4_4_4, buffer);
			}

			public int getWidth () {
				return 512;
			}

			public int getHeight () {
				return 512;
			}
		}));
	}
<commit_msg>[changed] TextureDataTest now uses a Pixmap, old code left in, commented.<commit_after>/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.badlogic.gdx.tests;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.tests.utils.GdxTest;

public class TextureDataTest extends GdxTest {
	private SpriteBatch spriteBatch;
	private Sprite sprite;

	public void create () {
		spriteBatch = new SpriteBatch();

		sprite = new Sprite(new Texture(new TextureData() {
//			public void load () {
//				FileHandle file = Gdx.files.internal("data/raw.bin");
//				InputStream input = file.read();
//				ByteBuffer buffer = ByteBuffer.allocateDirect((int)file.length());
//				buffer.order(ByteOrder.nativeOrder());
//				byte[] bytes = new byte[1024];
//				try {
//					while (true) {
//						int length = input.read(bytes);
//						if (length == -1) break;
//						buffer.put(bytes, 0, length);
//					}
//				} catch (IOException ex) {
//					throw new GdxRuntimeException(ex);
//				}
//				buffer.flip();
//				Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, getWidth(), getHeight(), 0, GL10.GL_RGBA,
//					GL10.GL_UNSIGNED_SHORT_4_4_4_4, buffer);
//			}
//
//			public int getWidth () {
//				return 512;
//			}
//
//			public int getHeight () {
//				return 512;
//			}
			
			int width = 0;
			int height = 0;
			
			public void load() {
				Pixmap pixmap = new Pixmap(Gdx.files.internal("data/badlogicsmall.jpg"));
				Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
				width = pixmap.getWidth();
				height = pixmap.getHeight();
				pixmap.dispose();
			}
			
			public int getWidth() {
				return width;
			}
			
			public int getHeight() {
				return height;
			}
		}));
	}

{'fraction_non_alphanumeric': 0.17633228840125392, 'fraction_numerical': 0.017241379310344827, 'mean_word_length': 3.6964121435142596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3019271', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1569, 'n_words': 417}