Skip to content

Instantly share code, notes, and snippets.

@chakmeshma
Created September 23, 2024 14:11
Show Gist options
  • Select an option

  • Save chakmeshma/fcf212004359b38806826ca68af458ad to your computer and use it in GitHub Desktop.

Select an option

Save chakmeshma/fcf212004359b38806826ca68af458ad to your computer and use it in GitHub Desktop.
using System.Runtime.InteropServices;
using System;
using UnityEngine;
using System.Drawing;
public class TextureSlicer : MonoBehaviour
{
[DllImport("DevILWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr getImagedata(string filePath, out int width, out int height);
void Start()
{
int width, height;
IntPtr imageData = getImagedata("C:\\Users\\chakm\\OneDrive\\Desktop\\testb.png", out width, out height);
int arraySize = (width * height * 3) + 6;
byte[] managedArray = new byte[arraySize];
Marshal.Copy(imageData, managedArray, 0, arraySize);
for (int i = 0; i < arraySize; i++)
{
Debug.Log(managedArray[i]);
}
}
void Update()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment