Author Topic: [Ndless] n2DLib  (Read 26763 times)

0 Members and 1 Guest are viewing this topic.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: [Ndless] n2DLib
« Reply #60 on: July 11, 2014, 02:40:58 pm »
A bmp doesn't have transparency so it uses the default value, if you convert it to a png and erase the background it works.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [Ndless] n2DLib
« Reply #61 on: July 11, 2014, 02:42:51 pm »
Oh nice. Looks like I wasted some time. :P That was a quick script anyway, I picked up some more Python along the way so no biggie.
You should change the default to magenta though.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: [Ndless] n2DLib
« Reply #62 on: July 11, 2014, 03:03:13 pm »
Bug fixed, for images without transparency it uses a color which doesn't appear in the image, so it's entirely opaque as you would expect.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless] n2DLib
« Reply #63 on: July 11, 2014, 03:08:16 pm »
Well, the point was that for example with my image the magenta 0xf81f pixels were transparent <_< for instance I don't feel like re-editing all of the 80 images nKaruga uses to convert them from magenta to alpha .-.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: [Ndless] n2DLib
« Reply #64 on: July 11, 2014, 03:10:12 pm »
* Streetwalrus prods Matref with imagemagick.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless] n2DLib
« Reply #65 on: July 11, 2014, 03:16:17 pm »
I have no idea what you're talking about.

Alright so back on-topic, I did my best at removing every branch and well, I can't really say if speed changed because it's always insanely fast on GS calcs, someone with a color calc will have to try it.

http://www.mirari.fr/eTV6

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: [Ndless] n2DLib
« Reply #66 on: July 11, 2014, 03:28:15 pm »
convert input.bmp -transparent 'ff00ff' out.png

That should take a bitmap and convert it to a png, while considering any of the magenta pixels as transparent. Change the hex to change the background color.


This is the imagemagick convert command. It's an extremely powerful image manipulation tool.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless] n2DLib
« Reply #67 on: July 11, 2014, 03:32:13 pm »
Well, I already have PNGs, but they have disabled alpha channels and have magenta pixels instead. But I'll try that.

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: [Ndless] n2DLib
« Reply #68 on: July 11, 2014, 03:40:35 pm »
You should be able to use a PNG as the input for the same effect, and you can set it up for bmp out if that's what you want. It autodetects the desired type based on the filename. (There's an option if you want to specify, but for this it's not necessary)

Offline Everkosus

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Re: [Ndless] n2DLib
« Reply #69 on: September 13, 2014, 06:54:54 am »

Hey grate lib, but in my opinion there should be a function that loads a image from a file, so i made a function that does that. Maybe you want to include this function in to you lib.


Code: [Select]
unsigned short* imageLoadFromFile(char *path){

FILE* readFile = fopen(path, "rb" );
if(readFile == NULL){
return NULL;
}


fseek(readFile, 0L, SEEK_END);
int size = ftell(readFile);
fseek(readFile, 0L, SEEK_SET);

unsigned short *array;


array = (unsigned short *) malloc(size);


if(array == NULL) {
return NULL;
}
int i;
for(i = 0; i < size/2; i++){
array[i] = fgetc(readFile) << 8;
array[i] += fgetc(readFile);
}
fclose(readFile);
return array;
}

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless] n2DLib
« Reply #70 on: September 13, 2014, 07:58:35 am »
If a load-image-from-file function must be written, it will load an image from a .bmp file. Nobody puts an image into a raw file, much less decompressed R5G6B5 image data. Besides, the function will have to deal with the BMP format, what your function doesn't do.

If you think that could be a good addition in the lib, then I'll probably work on an all-BMP loading function.

Offline Everkosus

  • LV0 Newcomer (Next: 5)
  • Posts: 2
  • Rating: +0/-0
    • View Profile
Re: [Ndless] n2DLib
« Reply #71 on: September 13, 2014, 08:22:10 am »
Well i wrote a program which converts any image to the raw data and write it to a new file, but you're right a function that loads a .bmp and does the whole conversion would be much better. xD
I just thought the possibility to store the images in files and load them dynamically would be good.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: [Ndless] n2DLib
« Reply #72 on: February 18, 2015, 03:41:11 pm »
Bump,

I implemented the first non-trivial, actually useful feature in n2DLib : interpolation of any number of points on a curve !

Basically, given arrays of X coordinates, Y coordinates and times, calling interpolatePath(Fixed || Float) generates a function that passes by every point you gave at the instants you gave. Pretty nice for predefined enemy paths for example !

I did a version that uses n2DLib's fixed-point numbers if you prefer speed over accuracy, and also a version that uses "normal" floating-point numbers if you want better accuracy - note that the latter is around 50 times slower though, even though it's the same code.

For those who forgot it, the lib is there : https://github.com/n2DLib/n2DLib

Also, I'll let you guess which one is the floating-point one :