Subversion Repositories Kolibri OS

Rev

Rev 717 | Rev 999 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
717 mikedld 1
;;================================================================================================;;
2
;;//// libimg.asm //// (c) mike.dld, 2007-2008 ///////////////////////////////////////////////////;;
3
;;================================================================================================;;
4
;;                                                                                                ;;
5
;; This file is part of Common development libraries (Libs-Dev).                                  ;;
6
;;                                                                                                ;;
7
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
8
;; General Public License as published by the Free Software Foundation, either version 3 of the   ;;
9
;; License, or (at your option) any later version.                                                ;;
10
;;                                                                                                ;;
11
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without  ;;
12
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  ;;
13
;; General Public License for more details.                                                       ;;
14
;;                                                                                                ;;
15
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;;
16
;; see .                                                            ;;
17
;;                                                                                                ;;
18
;;================================================================================================;;
19
 
20
 
21
format MS COFF
22
 
23
public @EXPORT as 'EXPORTS'
24
 
25
include '../../../../struct.inc'
26
include '../../../../proc32.inc'
27
include '../../../../macros.inc'
28
purge section,mov;add,sub
29
 
30
include 'libimg.inc'
31
 
32
section '.flat' code readable align 16
33
 
34
include 'bmp/bmp.asm'
35
include 'gif/gif.asm'
36
 
37
mem.alloc   dd ?
38
mem.free    dd ?
39
mem.realloc dd ?
40
dll.load    dd ?
41
 
42
;;================================================================================================;;
43
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
44
;;------------------------------------------------------------------------------------------------;;
45
;? Library entry point (called after library load)                                                ;;
46
;;------------------------------------------------------------------------------------------------;;
47
;> eax = pointer to memory allocation routine                                                     ;;
48
;> ebx = pointer to memory freeing routine                                                        ;;
49
;> ecx = pointer to memory reallocation routine                                                   ;;
50
;> edx = pointer to library loading routine                                                       ;;
51
;;------------------------------------------------------------------------------------------------;;
52
;< eax = 1 (fail) / 0 (ok) (library initialization result)                                        ;;
53
;;================================================================================================;;
54
	mov	[mem.alloc], eax
55
	mov	[mem.free], ebx
56
	mov	[mem.realloc], ecx
57
	mov	[dll.load], edx
58
 
59
  .ok:	xor	eax,eax
60
	ret
61
endp
62
 
63
;;================================================================================================;;
64
proc img.is_img _data, _length ;//////////////////////////////////////////////////////////////////;;
65
;;------------------------------------------------------------------------------------------------;;
66
;? --- TBD ---                                                                                    ;;
67
;;------------------------------------------------------------------------------------------------;;
68
;> --- TBD ---                                                                                    ;;
69
;;------------------------------------------------------------------------------------------------;;
70
;< --- TBD ---                                                                                    ;;
71
;;================================================================================================;;
72
	push	ebx
73
	mov	ebx, img._.formats_table
74
    @@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
75
	or	eax, eax
76
	jnz	@f
77
	add	ebx, sizeof.FormatsTableEntry
78
	cmp	dword[ebx], 0
79
	jnz	@b
80
	xor	eax, eax
81
    @@: pop	ebx
82
	ret
83
endp
84
 
85
;;================================================================================================;;
86
proc img.info _data, _length ;////////////////////////////////////////////////////////////////////;;
87
;;------------------------------------------------------------------------------------------------;;
88
;? --- TBD ---                                                                                    ;;
89
;;------------------------------------------------------------------------------------------------;;
90
;> --- TBD ---                                                                                    ;;
91
;;------------------------------------------------------------------------------------------------;;
92
;< --- TBD ---                                                                                    ;;
93
;;================================================================================================;;
94
	xor	eax, eax
95
	ret
96
endp
97
 
98
;;================================================================================================;;
99
proc img.from_file _filename ;////////////////////////////////////////////////////////////////////;;
100
;;------------------------------------------------------------------------------------------------;;
101
;? --- TBD ---                                                                                    ;;
102
;;------------------------------------------------------------------------------------------------;;
103
;> --- TBD ---                                                                                    ;;
104
;;------------------------------------------------------------------------------------------------;;
105
;< eax = 0 / pointer to image                                                                     ;;
106
;;================================================================================================;;
107
	xor	eax, eax
108
	ret
109
endp
110
 
111
;;================================================================================================;;
112
proc img.to_file _img, _filename ;////////////////////////////////////////////////////////////////;;
113
;;------------------------------------------------------------------------------------------------;;
114
;? --- TBD ---                                                                                    ;;
115
;;------------------------------------------------------------------------------------------------;;
116
;> --- TBD ---                                                                                    ;;
117
;;------------------------------------------------------------------------------------------------;;
118
;< eax = false / true                                                                             ;;
119
;;================================================================================================;;
120
	xor	eax, eax
121
	ret
122
endp
123
 
124
;;================================================================================================;;
125
proc img.from_rgb _rgb_data ;/////////////////////////////////////////////////////////////////////;;
126
;;------------------------------------------------------------------------------------------------;;
127
;? --- TBD ---                                                                                    ;;
128
;;------------------------------------------------------------------------------------------------;;
129
;> --- TBD ---                                                                                    ;;
130
;;------------------------------------------------------------------------------------------------;;
131
;< eax = 0 / pointer to image                                                                     ;;
132
;;================================================================================================;;
133
	xor	eax, eax
134
	ret
135
endp
136
 
137
;;================================================================================================;;
138
proc img.to_rgb _img ;////////////////////////////////////////////////////////////////////////////;;
139
;;------------------------------------------------------------------------------------------------;;
140
;? --- TBD ---                                                                                    ;;
141
;;------------------------------------------------------------------------------------------------;;
142
;> --- TBD ---                                                                                    ;;
143
;;------------------------------------------------------------------------------------------------;;
144
;< eax = 0 / pointer to rgb_data (array of [rgb] triplets)                                        ;;
145
;;================================================================================================;;
146
	push	esi edi
147
	stdcall img._.validate, [_img]
148
	or	eax, eax
149
	jnz	.error
150
 
151
	mov	esi, [_img]
152
	mov	ecx, [esi + Image.Width]
153
	imul	ecx, [esi + Image.Height]
154
	lea	eax, [ecx * 3 + 4 * 3]
155
	invoke	mem.alloc, eax
156
	or	eax, eax
157
	jz	.error
158
 
159
	mov	edi, eax
160
	push	eax
161
	mov	eax, [esi + Image.Width]
162
	stosd
163
	mov	eax, [esi + Image.Height]
164
	stosd
165
	mov	esi, [esi + Image.Data]
166
 
167
    @@: dec	ecx
168
	js	@f
169
	movsd
170
	dec	edi
171
	jmp	@b
172
 
173
    @@: pop	eax
174
	pop	edi esi
175
	ret
176
 
177
  .error:
178
	xor	eax, eax
179
	pop	edi esi
180
	ret
181
endp
182
 
183
;;================================================================================================;;
184
proc img.decode _data, _length ;//////////////////////////////////////////////////////////////////;;
185
;;------------------------------------------------------------------------------------------------;;
186
;? --- TBD ---                                                                                    ;;
187
;;------------------------------------------------------------------------------------------------;;
188
;> --- TBD ---                                                                                    ;;
189
;;------------------------------------------------------------------------------------------------;;
190
;< eax = 0 / pointer to image                                                                     ;;
191
;;================================================================================================;;
192
	push	ebx
193
	mov	ebx, img._.formats_table
194
    @@: stdcall [ebx + FormatsTableEntry.Is], [_data], [_length]
195
	or	eax, eax
196
	jnz	@f
197
	add	ebx, sizeof.FormatsTableEntry
198
	cmp	dword[ebx], 0
199
	jnz	@f
200
	jmp	.error
201
    @@: stdcall [ebx + FormatsTableEntry.Decode], [_data], [_length]
202
 
203
  .error:
204
	ret
205
endp
206
 
207
;;================================================================================================;;
208
proc img.encode _img, _p_length ;/////////////////////////////////////////////////////////////////;;
209
;;------------------------------------------------------------------------------------------------;;
210
;? --- TBD ---                                                                                    ;;
211
;;------------------------------------------------------------------------------------------------;;
212
;> --- TBD ---                                                                                    ;;
213
;;------------------------------------------------------------------------------------------------;;
214
;< eax = 0 / pointer to encoded data                                                              ;;
215
;< [_p_length] = data length                                                                      ;;
216
;;================================================================================================;;
217
	xor	eax, eax
218
	ret
219
endp
220
 
221
;;================================================================================================;;
222
proc img.create _width, _height ;/////////////////////////////////////////////////////////////////;;
223
;;------------------------------------------------------------------------------------------------;;
224
;? --- TBD ---                                                                                    ;;
225
;;------------------------------------------------------------------------------------------------;;
226
;> --- TBD ---                                                                                    ;;
227
;;------------------------------------------------------------------------------------------------;;
228
;< eax = 0 / pointer to image                                                                     ;;
229
;;================================================================================================;;
230
	push	ecx
231
 
232
	stdcall img._.new
233
	or	eax, eax
234
	jz	.error
235
 
236
	push	eax
237
 
783 mikedld 238
	stdcall img._.resize_data, eax, [_width], [_height]
717 mikedld 239
	or	eax, eax
240
	jz	.error.2
241
 
242
	pop	eax
243
	ret
244
 
245
  .error.2:
246
;       pop     eax
247
	stdcall img._.delete; eax
248
	xor	eax, eax
249
 
250
  .error:
251
	pop	ecx
252
	ret
253
endp
254
 
255
;;================================================================================================;;
256
proc img.destroy _img ;///////////////////////////////////////////////////////////////////////////;;
257
;;------------------------------------------------------------------------------------------------;;
258
;? --- TBD ---                                                                                    ;;
259
;;------------------------------------------------------------------------------------------------;;
260
;> --- TBD ---                                                                                    ;;
261
;;------------------------------------------------------------------------------------------------;;
262
;< eax = false / true                                                                             ;;
263
;;================================================================================================;;
264
	;TODO: link Next and Previous
265
	stdcall img._.delete, [_img]
266
	ret
267
endp
268
 
269
;;================================================================================================;;
783 mikedld 270
proc img.count _img ;/////////////////////////////////////////////////////////////////////////////;;
717 mikedld 271
;;------------------------------------------------------------------------------------------------;;
783 mikedld 272
;? Get number of images in the list (e.g. in animated GIF file)                                   ;;
717 mikedld 273
;;------------------------------------------------------------------------------------------------;;
783 mikedld 274
;> _img = pointer to image                                                                        ;;
717 mikedld 275
;;------------------------------------------------------------------------------------------------;;
783 mikedld 276
;< eax = -1 (fail) / >0 (ok)                                                                      ;;
717 mikedld 277
;;================================================================================================;;
783 mikedld 278
	push	ecx edx
279
	mov	edx, [_img]
280
	stdcall img._.validate, edx
717 mikedld 281
	or	eax, eax
783 mikedld 282
	jnz	.error
717 mikedld 283
 
783 mikedld 284
    @@: mov	eax, [edx + Image.Previous]
285
	or	eax, eax
286
	jz	@f
287
	mov	edx, eax
288
	jmp	@b
717 mikedld 289
 
783 mikedld 290
    @@: xor	ecx, ecx
291
    @@: inc	ecx
292
	mov	eax, [edx + Image.Next]
293
	or	eax, eax
294
	jz	.exit
295
	mov	edx, eax
296
	jmp	@b
297
 
298
  .exit:
299
	mov	eax, ecx
300
	pop	edx ecx
301
	ret
302
 
717 mikedld 303
  .error:
783 mikedld 304
	or	eax, -1
305
	pop	edx ecx
717 mikedld 306
	ret
307
endp
308
 
783 mikedld 309
;;//// image processing //////////////////////////////////////////////////////////////////////////;;
310
 
717 mikedld 311
;;================================================================================================;;
312
proc img.lock_bits _img, _start_line, _end_line ;/////////////////////////////////////////////////;;
313
;;------------------------------------------------------------------------------------------------;;
314
;? --- TBD ---                                                                                    ;;
315
;;------------------------------------------------------------------------------------------------;;
316
;> --- TBD ---                                                                                    ;;
317
;;------------------------------------------------------------------------------------------------;;
318
;< eax = 0 / pointer to bits                                                                      ;;
319
;;================================================================================================;;
320
	xor	eax, eax
321
	ret
322
endp
323
 
324
;;================================================================================================;;
325
proc img.unlock_bits _img, _lock ;////////////////////////////////////////////////////////////////;;
326
;;------------------------------------------------------------------------------------------------;;
327
;? --- TBD ---                                                                                    ;;
328
;;------------------------------------------------------------------------------------------------;;
329
;> --- TBD ---                                                                                    ;;
330
;;------------------------------------------------------------------------------------------------;;
331
;< eax = false / true                                                                             ;;
332
;;================================================================================================;;
333
	xor	eax, eax
334
	ret
335
endp
336
 
337
;;================================================================================================;;
338
proc img.flip _img, _flip_kind ;//////////////////////////////////////////////////////////////////;;
339
;;------------------------------------------------------------------------------------------------;;
783 mikedld 340
;? Flip image                                                                                     ;;
717 mikedld 341
;;------------------------------------------------------------------------------------------------;;
783 mikedld 342
;> _img = pointer to image                                                                        ;;
343
;> _flip_kind = one of FLIP_* constants                                                           ;;
717 mikedld 344
;;------------------------------------------------------------------------------------------------;;
783 mikedld 345
;< eax = false / true                                                                             ;;
717 mikedld 346
;;================================================================================================;;
347
locals
348
  scanline_len dd ?
349
endl
350
 
351
	push	esi edi
352
	stdcall img._.validate, [_img]
353
	or	eax, eax
354
	jnz	.error
355
 
356
	mov	esi, [_img]
357
	mov	ecx, [esi + Image.Height]
358
	mov	eax, [esi + Image.Width]
359
	shl	eax, 2
360
	mov	[scanline_len], eax
361
 
783 mikedld 362
	push	esi
363
 
717 mikedld 364
	test	[_flip_kind], FLIP_VERTICAL
365
	jz	.dont_flip_vert
366
 
367
	imul	eax, ecx
368
	sub	eax, [scanline_len]
369
	shr	ecx, 1
370
	mov	esi, [esi + Image.Data]
371
	lea	edi, [esi + eax]
372
 
373
  .next_line_vert:
374
	push	ecx
375
 
376
	mov	ecx, [scanline_len]
783 mikedld 377
	shr	ecx, 2
717 mikedld 378
    @@: lodsd
379
	xchg	eax, [edi]
380
	mov	[esi - 4], eax
381
	add	edi, 4
783 mikedld 382
	dec	ecx
717 mikedld 383
	jnz	@b
384
 
783 mikedld 385
	pop	ecx
717 mikedld 386
	mov	eax, [scanline_len]
387
	shl	eax, 1
388
	sub	edi, eax
389
	dec	ecx
390
	jnz	.next_line_vert
391
 
392
  .dont_flip_vert:
393
 
783 mikedld 394
	pop	esi
395
 
717 mikedld 396
	test	[_flip_kind], FLIP_HORIZONTAL
397
	jz	.exit
398
 
783 mikedld 399
	mov	ecx, [esi + Image.Height]
400
	mov	esi, [esi + Image.Data]
401
	lea	edi, [esi - 4]
402
	add	edi, [scanline_len]
717 mikedld 403
 
783 mikedld 404
  .next_line_horz:
405
	push	ecx esi edi
406
 
407
	mov	ecx, [scanline_len]
408
	shr	ecx, 3
409
    @@: mov	eax, [esi]
410
	xchg	eax, [edi]
411
	mov	[esi], eax
412
	add	esi, 4
413
	add	edi, -4
414
	dec	ecx
415
	jnz	@b
416
 
417
	pop	edi esi ecx
418
	add	esi, [scanline_len]
419
	add	edi, [scanline_len]
420
	dec	ecx
421
	jnz	.next_line_horz
422
 
717 mikedld 423
  .exit:
424
	xor	eax, eax
425
	inc	eax
426
	pop	edi esi
427
	ret
428
 
429
  .error:
430
	xor	eax, eax
431
	pop	edi esi
432
	ret
433
endp
434
 
783 mikedld 435
;;================================================================================================;;
436
proc img.rotate _img, _rotate_kind ;//////////////////////////////////////////////////////////////;;
437
;;------------------------------------------------------------------------------------------------;;
438
;? Rotate image                                                                                   ;;
439
;;------------------------------------------------------------------------------------------------;;
440
;> _img = pointer to image                                                                        ;;
441
;> _rotate_kind = one of ROTATE_* constants                                                       ;;
442
;;------------------------------------------------------------------------------------------------;;
443
;< eax = false / true                                                                             ;;
444
;;================================================================================================;;
445
locals
446
  scanline_len_old    dd ?
447
  scanline_len_new    dd ?
448
  scanline_pixels_new dd ?
449
  line_buffer	      dd ?
450
  pixels_ptr	      dd ?
451
endl
717 mikedld 452
 
783 mikedld 453
	mov	[line_buffer], 0
454
 
455
	push	ebx esi edi
456
	stdcall img._.validate, [_img]
457
	or	eax, eax
458
	jnz	.error
459
 
460
	cmp	[_rotate_kind], ROTATE_90_CCW
461
	je	.rotate_ccw_low
462
	cmp	[_rotate_kind], ROTATE_90_CW
463
	je	.rotate_cw_low
464
	cmp	[_rotate_kind], ROTATE_180
465
	je	.flip
466
	jmp	.exit
467
 
468
  .rotate_ccw_low:
469
	mov	ebx, [_img]
470
	mov	eax, [ebx + Image.Height]
471
	mov	[scanline_pixels_new], eax
472
	shl	eax, 2
473
	mov	[scanline_len_new], eax
474
 
475
	invoke	mem.alloc, eax
476
	or	eax, eax
477
	jz	.error
478
	mov	[line_buffer], eax
479
 
480
	mov	ecx, [ebx + Image.Width]
481
	lea	eax, [ecx * 4]
482
	mov	[scanline_len_old], eax
483
 
484
	mov	eax, [scanline_len_new]
485
	imul	eax, ecx
486
	add	eax, [ebx + Image.Data]
487
	mov	[pixels_ptr], eax
488
 
489
  .next_column_ccw_low:
490
	dec	ecx
491
	jz	.exchange_dims
492
	push	ecx
493
 
494
	mov	edx, [scanline_len_old]
495
	add	[scanline_len_old], -4
496
 
497
	mov	ecx, [scanline_pixels_new]
498
	mov	esi, [ebx + Image.Data]
499
	mov	edi, [line_buffer]
500
    @@: mov	eax, [esi]
501
	stosd
502
	add	esi, edx
503
	dec	ecx
504
	jnz	@b
505
 
506
	mov	eax, [scanline_pixels_new]
507
	mov	edi, [ebx + Image.Data]
508
	lea	esi, [edi + 4]
509
	mov	edx, [scanline_len_old]
510
	shr	edx, 2
511
    @@: mov	ecx, edx
512
	rep	movsd
513
	add	esi, 4
514
	dec	eax
515
	jnz	@b
516
 
517
	mov	eax, [scanline_len_new]
518
	sub	[pixels_ptr], eax
519
	mov	ecx, [scanline_pixels_new]
520
	mov	esi, [line_buffer]
521
	mov	edi, [pixels_ptr]
522
	rep	movsd
523
 
524
	pop	ecx
525
	jmp	.next_column_ccw_low
526
 
527
  .rotate_cw_low:
528
	mov	ebx, [_img]
529
	mov	eax, [ebx + Image.Height]
530
	mov	[scanline_pixels_new], eax
531
	shl	eax, 2
532
	mov	[scanline_len_new], eax
533
 
534
	invoke	mem.alloc, eax
535
	or	eax, eax
536
	jz	.error
537
	mov	[line_buffer], eax
538
 
539
	mov	ecx, [ebx + Image.Width]
540
	lea	eax, [ecx * 4]
541
	mov	[scanline_len_old], eax
542
 
543
	mov	eax, [scanline_len_new]
544
	imul	eax, ecx
545
	add	eax, [ebx + Image.Data]
546
	mov	[pixels_ptr], eax
547
 
548
  .next_column_cw_low:
549
	dec	ecx
550
	js	.exchange_dims
551
	push	ecx
552
 
553
	mov	edx, [scanline_len_old]
554
	add	[scanline_len_old], -4
555
 
556
	mov	ecx, [scanline_pixels_new]
557
	mov	esi, [pixels_ptr]
558
	add	esi, -4
559
	mov	edi, [line_buffer]
560
    @@: mov	eax, [esi]
561
	stosd
562
	sub	esi, edx
563
	dec	ecx
564
	jnz	@b
565
 
566
	mov	eax, [scanline_pixels_new]
567
	dec	eax
568
	mov	edi, [ebx + Image.Data]
569
	add	edi, [scanline_len_old]
570
	lea	esi, [edi + 4]
571
	mov	edx, [scanline_len_old]
572
	shr	edx, 2
573
    @@: mov	ecx, edx
574
	rep	movsd
575
	add	esi, 4
576
	dec	eax
577
	jnz	@b
578
 
579
	mov	eax, [scanline_len_new]
580
	sub	[pixels_ptr], eax
581
	mov	ecx, [scanline_pixels_new]
582
	mov	esi, [line_buffer]
583
	mov	edi, [pixels_ptr]
584
	rep	movsd
585
 
586
	pop	ecx
587
	jmp	.next_column_cw_low
588
 
589
  .flip:
590
	jmp	.exit
591
 
592
  .exchange_dims:
593
	push	[ebx + Image.Width] [ebx + Image.Height]
594
	pop	[ebx + Image.Width] [ebx + Image.Height]
595
 
596
  .exit:
597
	invoke	mem.free, [line_buffer]
598
	xor	eax, eax
599
	inc	eax
600
	pop	edi esi ebx
601
	ret
602
 
603
  .error:
604
	invoke	mem.free, [line_buffer]
605
	xor	eax, eax
606
	pop	edi esi ebx
607
	ret
608
endp
609
 
610
 
717 mikedld 611
;;================================================================================================;;
612
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
613
;;================================================================================================;;
614
;! Below are private procs you should never call directly from your code                          ;;
615
;;================================================================================================;;
616
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
617
;;================================================================================================;;
618
 
619
 
620
;;================================================================================================;;
621
proc img._.validate, _img ;///////////////////////////////////////////////////////////////////////;;
622
;;------------------------------------------------------------------------------------------------;;
623
;? --- TBD ---                                                                                    ;;
624
;;------------------------------------------------------------------------------------------------;;
625
;> --- TBD ---                                                                                    ;;
626
;;------------------------------------------------------------------------------------------------;;
627
;< --- TBD ---                                                                                    ;;
628
;;================================================================================================;;
629
	xor	eax, eax
630
	ret
631
endp
632
 
633
;;================================================================================================;;
634
proc img._.new ;//////////////////////////////////////////////////////////////////////////////////;;
635
;;------------------------------------------------------------------------------------------------;;
636
;? --- TBD ---                                                                                    ;;
637
;;------------------------------------------------------------------------------------------------;;
638
;> --- TBD ---                                                                                    ;;
639
;;------------------------------------------------------------------------------------------------;;
640
;< eax = 0 / pointer to image                                                                     ;;
641
;;================================================================================================;;
642
	invoke	mem.alloc, sizeof.Image
643
	ret
644
endp
645
 
646
;;================================================================================================;;
647
proc img._.delete _img ;//////////////////////////////////////////////////////////////////////////;;
648
;;------------------------------------------------------------------------------------------------;;
649
;? --- TBD ---                                                                                    ;;
650
;;------------------------------------------------------------------------------------------------;;
651
;> --- TBD ---                                                                                    ;;
652
;;------------------------------------------------------------------------------------------------;;
653
;< eax = false / true                                                                             ;;
654
;;================================================================================================;;
655
	push	edx
656
	mov	edx, [_img]
657
	cmp	[edx + Image.Data], 0
658
	je	@f
659
	invoke	mem.free, [edx + Image.Data]
660
    @@: cmp	[edx + Image.Extended], 0
661
	je	@f
662
	invoke	mem.free, [edx + Image.Extended]
663
    @@: invoke	mem.free, edx
664
	pop	edx
665
	ret
666
endp
667
 
783 mikedld 668
;;================================================================================================;;
669
proc img._.resize_data _img, _width, _height ;////////////////////////////////////////////////////;;
670
;;------------------------------------------------------------------------------------------------;;
671
;? --- TBD ---                                                                                    ;;
672
;;------------------------------------------------------------------------------------------------;;
673
;> --- TBD ---                                                                                    ;;
674
;;------------------------------------------------------------------------------------------------;;
675
;< --- TBD ---                                                                                    ;;
676
;;================================================================================================;;
677
	push	ebx
678
	mov	ebx, [_img]
679
	mov	eax, [_height]
680
	imul	eax, [_width]
681
	shl	eax, 2
682
	invoke	mem.realloc, [ebx + Image.Data], eax
683
	or	eax, eax
684
	jz	.error
717 mikedld 685
 
783 mikedld 686
	mov	[ebx + Image.Data], eax
687
	push	[_width]
688
	pop	[ebx + Image.Width]
689
	push	[_height]
690
	pop	[ebx + Image.Height]
691
 
692
  .error:
693
	pop	ebx
694
	ret
695
endp
696
 
697
 
717 mikedld 698
;;================================================================================================;;
699
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
700
;;================================================================================================;;
701
;! Below is private data you should never use directly from your code                             ;;
702
;;================================================================================================;;
703
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
704
;;================================================================================================;;
705
 
706
 
707
img._.formats_table:
708
  .bmp dd img.is.bmp, img.decode.bmp, img.encode.bmp
709
; .ico dd img.is.ico, img.decode.ico, img.encode.ico
710
; .cur dd img.is.cur, img.decode.cur, img.encode.cur
711
  .gif dd img.is.gif, img.decode.gif, img.encode.gif
712
; .png dd img.is.png, img.decode.png, img.encode.png
713
; .jpg dd img.is.jpg, img.decode.jpg, img.encode.jpg
714
       dd 0
715
 
716
 
717
;;================================================================================================;;
718
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
719
;;================================================================================================;;
720
;! Exported functions section                                                                     ;;
721
;;================================================================================================;;
722
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
723
;;================================================================================================;;
724
 
725
 
726
align 16
727
@EXPORT:
728
 
729
export					      \
730
	lib_init	, 'lib_init'	    , \
731
	0x00010001	, 'version'	    , \
732
	img.is_img	, 'img.is_img'	    , \
733
	img.info	, 'img.info'	    , \
734
	img.from_file	, 'img.from_file'   , \
735
	img.to_file	, 'img.to_file'     , \
736
	img.from_rgb	, 'img.from_rgb'    , \
737
	img.to_rgb	, 'img.to_rgb'	    , \
738
	img.decode	, 'img.decode'	    , \
739
	img.encode	, 'img.encode'	    , \
740
	img.create	, 'img.create'	    , \
741
	img.destroy	, 'img.destroy'     , \
783 mikedld 742
	img.count	, 'img.count'	    , \
717 mikedld 743
	img.lock_bits	, 'img.lock_bits'   , \
783 mikedld 744
	img.unlock_bits , 'img.unlock_bits' , \
745
	img.flip	, 'img.flip'	    , \
746
	img.rotate	, 'img.rotate'