Specs for various image formats?
of course i could just create my own raw image format, and i probably will, but i still need the ability to import/export other formats (probably only jpeg and png) and while i could, i guess, use various libs for the task, it's is my experience that thing work best if you do it your self.
As for the png part i am really really close, there is just a tiny little part that i don't understand.
I haven't investigated jpeg yet, but my guest is that it won't be too hard either.
As for the png part i am really really close, there is just a tiny little part that i don't understand.
I haven't investigated jpeg yet, but my guest is that it won't be too hard either.
Last edited by Zacariaz on Tue Mar 04, 2008 11:35 am, edited 1 time in total.
This was supposed to be a cool signature...
But this is not the ? you asked, You wanted a uncompressed image format, with alpha support and the only one's available are rare, so you would be best writing your own.
The point that you will need to support other file format is true for all OS used today.
Also most of the other image formats are compressed.
But you start with a simple format usually bmp or your own and work your way up.
The point that you will need to support other file format is true for all OS used today.
Also most of the other image formats are compressed.
But you start with a simple format usually bmp or your own and work your way up.
I actually had writen very long reply, but instead i descided to restate my my question.
"I need an lossless image format which is not to complicated. Which would you recomment?" but then again i have allready found that PNG and me work work together pretty well, there is just that little tiny bit which i can't understand.
So, my question, if i should bother restating it, must be: "Where can i get some complete specs for the png image format?" but im pretty sure that the specs i allready have are complete, its just me who can understand it. I just wish i knew what it was, then i would know how to ask the right question.
Thus the only option left is getting hold of someone who have some experience with png.
By the way i do find png simple, much more than i would have thought before i started. This post was really one of those: "i want to do this, but its probably too complicated for me." as it turns out, this isn't true, but i do need help.
"I need an lossless image format which is not to complicated. Which would you recomment?" but then again i have allready found that PNG and me work work together pretty well, there is just that little tiny bit which i can't understand.
So, my question, if i should bother restating it, must be: "Where can i get some complete specs for the png image format?" but im pretty sure that the specs i allready have are complete, its just me who can understand it. I just wish i knew what it was, then i would know how to ask the right question.
Thus the only option left is getting hold of someone who have some experience with png.
By the way i do find png simple, much more than i would have thought before i started. This post was really one of those: "i want to do this, but its probably too complicated for me." as it turns out, this isn't true, but i do need help.
This was supposed to be a cool signature...
http://www.libpng.org/pub/png/pngdocs.html is your safest bet.Zacariaz wrote:So, my question, if i should bother restating it, must be: "Where can i get some complete specs for the png image format?" but im pretty sure that the specs i allready have are complete...
I found PNG to be heavily influenced by the IFF metaformat, which was proposed by Electronic Arts in 1985. As most of the "early" formats, it was from techies for techies, and it shows. While IFF itself more or less died together with the AmigaOS, there are many quite successful deviants of the format (RIFF WAV, AIFF, PNG) still around today.By the way i do find png simple, much more than i would have thought before i started.
Every good solution is obvious once you've found it.
yah. i think there is a problem with colour palette(i tried with other images and if i dont put the palette of the image, i get a ugly one, else i could put on the screen images verry well) and with the size.Dex wrote:If you used it right, it would come out like the posted image.
Note: There's two icon's displayed in this image.
Also, i made a program that converts a bmp image into an asm file that have the image(as pixels array) and the palette of the image.
who wants to post the code?
And that is exactly the docs im using, atlest from the same site, but still when looking at a sample image there is data in the IDAT chunk that should be there according to the docs, that is atleast how i interpet them.Solar wrote:http://www.libpng.org/pub/png/pngdocs.html is your safest bet.Zacariaz wrote:So, my question, if i should bother restating it, must be: "Where can i get some complete specs for the png image format?" but im pretty sure that the specs i allready have are complete...
Here is the data in hex: (uncompressed no nothing 1 pixel png image)
Code: Select all
[signature]89 50 4e 47 0d 0a 1a 0a[/signature]
[IHDR]
[chunk-length]00 00 00 0d[/chunk-length]
[chunk-type]49 48 44 52[/chunk-type]
[width]00 00 00 01[/width]
[height]00 00 00 01[/height]
[bit-depth]08[/bit-depth]
[color-type]02[/color-type]
[compression-methode]00[/compression-methode]
[filter-methode]00[/filter-methode]
[interlace-methode]00[/interlace-methode]
[CRC]90 77 53 de[/CRC]
[/IHDR]
[IDAT]
[chunk-length]00 00 00 0f[/chunk-length]
[chunk-type]49 44 41 54[/chunk-type]
[?]78 01 01 04 00 fb ff 00[/?]
[pixel-value]23 57 bd[/pixel-value]
[?]01 d8 01 38[/?]
[CRC]18 f1 06 f3[/CRC]
[/IDAT]
[IEND]
[chunk-length]00 00 00 00[/chunk-length]
[chunk-type]49 45 4e 44[/chunk-type]
[CRC]ae 42 60 82[/CRC]
[/IEND]
Just for the sake of it i uploaded the test file, but i had to sip it, otherwise it would just show as a 1px image which is kinda hard to hit
- Attachments
-
- test2.zip
- (183 Bytes) Downloaded 28 times
This was supposed to be a cool signature...
This is a bit off topic, but to answer your ?.eddyb wrote:yah. i think there is a problem with colour palette(i tried with other images and if i dont put the palette of the image, i get a ugly one, else i could put on the screen images verry well) and with the size.Dex wrote:If you used it right, it would come out like the posted image.
Note: There's two icon's displayed in this image.
Also, i made a program that converts a bmp image into an asm file that have the image(as pixels array) and the palette of the image.
who wants to post the code?
I think you maybe mixing this up with 256 color 8bpp, this is for 24/32bpp, theres no palette, the format is RRGGBB for 24bpp and XXRRGGBB for 32bpp, XX in most caser's = 0x00.
So the color white, would be 0x00ffffff for 32bpp.
I have a bootable demo that sets up vesa and displays these icon's, if you want it and the code let me know.
PS: I would like to see your code, thanks.
yah, i use 256 colors, in mode 320x200
this is the code for my "transformer":
its transform a <name>.bmp image in a <name>.asm file with this content:
<name> is the argument
(eg if u want to transform music.bmp:)
to have many images, i use a batch that executes the prog for each image, then gather the images(asm images )(using comand) into a single .asm file.
Note: that's for 8 byte bitmaps.
this is the code for my "transformer":
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <sys/nearptr.h>
#include <string.h>
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;
typedef struct tagBITMAP /* the structure for a bitmap. */
{
word width;
word height;
byte palette[256*3];
byte *data;
} BITMAP;
/**************************************************************************
* fskip *
* Skips bytes in a file. *
**************************************************************************/
void fskip(FILE *fp, int num_bytes)
{
int i;
for (i=0; i<num_bytes; i++)
fgetc(fp);
}
void load_bmp(char *file,BITMAP *b)
{
FILE *fp;
long index;
word num_colors;
int x;
/* open the file */
if ((fp = fopen(file,"rb")) == NULL)
{
printf("Error opening file %s.\n",file);
exit(1);
}
/* check to see if it is a valid bitmap file */
if (fgetc(fp)!='B' || fgetc(fp)!='M')
{
fclose(fp);
printf("%s is not a bitmap file.\n",file);
exit(1);
}
/* read in the width and height of the image, and the
number of colors used; ignore the rest */
fskip(fp,16);
fread(&b->width, sizeof(word), 1, fp);
fskip(fp,2);
fread(&b->height,sizeof(word), 1, fp);
fskip(fp,22);
fread(&num_colors,sizeof(word), 1, fp);
fskip(fp,6);
/* assume we are working with an 8-bit file */
if (num_colors==0) num_colors=256;
/* try to allocate memory */
if ((b->data = (byte *) malloc((word)(b->width*b->height))) == NULL)
{
fclose(fp);
printf("Error allocating memory for file %s.\n",file);
exit(1);
}
/* read the palette information */
for(index=0;index<num_colors;index++)
{
b->palette[(int)(index*3+2)] = fgetc(fp) >> 2;
b->palette[(int)(index*3+1)] = fgetc(fp) >> 2;
b->palette[(int)(index*3+0)] = fgetc(fp) >> 2;
x=fgetc(fp);
}
/* read the bitmap */
for(index=(b->height-1)*b->width;index>=0;index-=b->width)
for(x=0;x<b->width;x++)
b->data[(word)(index+x)]=(byte)fgetc(fp);
fclose(fp);
}
int main(int argc, char * argv[])
{
if(argc<2)
{
puts("No arguments!\nUse: bitmap.exe [file_des]");
return;
}
int i,x,y;
char ch[256];
char chb[256];
char cha[256];
strcpy(ch, argv[1]);
strcpy(chb, ch);
strcpy(cha, ch);
strcat(chb, ".bmp");
strcat(cha, ".asm");
BITMAP bmp;
load_bmp(chb,&bmp); /* open the file */
FILE * fp;
fp = fopen(cha, "w");
fprintf(fp, ";%s bitmap file\n;transormed by edy\n\nglobal _%s\n_%s:\n", chb, ch, ch);
for(y=0;y<(bmp.width*bmp.height)/12;y++)
{
fprintf(fp, "db ");
for(x=0;x<12;x++)
{
if(x==11)
fprintf(fp, "%#X", bmp.data[x+y*12]);
else
fprintf(fp, "%#X,", bmp.data[x+y*12]);
}
fprintf(fp, "\n");
}
fprintf(fp, "\n\n;%s bitmap palette\n\nglobal _%s_palette\n_%s_palette:\n", chb, ch, ch);
for(y=0;y<(256*3)/12;y++)
{
fprintf(fp, "db ");
for(x=0;x<12;x++)
{
if(x==11)
fprintf(fp, "%#X", bmp.palette[x+y*12]);
else
fprintf(fp, "%#X,", bmp.palette[x+y*12]);
}
fprintf(fp, "\n");
}
printf("Image %s succefuly transformed\n whith res: %ux%u", chb, bmp.width, bmp.height);
getch();
return 0;
}
Code: Select all
;a comment...
<name>:
<here comes the data as pixels array>
<name>_palette:
<here comes the image palette>
(eg if u want to transform music.bmp:
Code: Select all
bitmap_conv music
to have many images, i use a batch that executes the prog for each image, then gather the images(asm images )(using comand
Code: Select all
copy \b img1.asm + img2.asm +... imgs.asm
Note: that's for 8 byte bitmaps.
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Code: Select all
int i;
for (i=0; i<num_bytes; i++)
fgetc(fp);
For realmode you can try vesa and bank switching, for info read these topic's and see my demo, to get 640*480 256 colors
http://www.osdev.org/phpBB2/viewtopic.p ... ight=vesa1
If you mean to use in pmode, theres also a demo of mine using vesa and LFB, lower down in the topic.
http://www.osdev.org/phpBB2/viewtopic.p ... ight=vesa1
If you mean to use in pmode, theres also a demo of mine using vesa and LFB, lower down in the topic.