1 | /** |
2 | * PIC_RW - Qt PIC Support |
3 | * Copyright (C) 2007 Ruben Lopez <r.lopez@bren.es> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * ---------------------------------------------------------------------------- |
19 | */ |
20 | |
21 | #include "pic_io_handler.h" |
22 | #include "pic_rw.h" |
23 | |
24 | bool SoftimagePICHandler::canRead() const { |
25 | if (!SoftimagePICHandler::canRead(device())) { |
26 | return false; |
27 | } |
28 | setFormat("pic" ); |
29 | return true; |
30 | } |
31 | |
32 | bool SoftimagePICHandler::read(QImage *image) { |
33 | pic_read(device(), image); |
34 | return true; |
35 | } |
36 | |
37 | bool SoftimagePICHandler::write(const QImage &image) { |
38 | pic_write(device(), &image); |
39 | return true; |
40 | } |
41 | |
42 | bool SoftimagePICHandler::canRead(QIODevice *device) { |
43 | PICHeader hdr; |
44 | if (picReadHeader(device, &hdr, true)) { |
45 | if (strncmp(hdr.id, "PICT" , 4) == 0) { |
46 | return true; |
47 | } |
48 | } |
49 | return false; |
50 | } |
51 | |
52 | QVariant SoftimagePICHandler::option(ImageOption option) const { |
53 | if (option == Size) { |
54 | PICHeader hdr; |
55 | if (picReadHeader(device(), &hdr, true)) { |
56 | return QSize(hdr.width, hdr.height); |
57 | } else { |
58 | return QSize(-1, -1); |
59 | } |
60 | } |
61 | return QVariant(); |
62 | } |
63 | |
64 | bool SoftimagePICHandler::supportsOption(ImageOption option) const { |
65 | return ( option == Size); |
66 | } |
67 | |
68 | QByteArray SoftimagePICHandler::name() const { |
69 | return "pic" ; |
70 | } |
71 | |
72 | |