Skip to content

Commit

Permalink
latest work on rom explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
phooky committed Aug 20, 2012
1 parent 084020c commit 0e3bb4e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 12 deletions.
18 changes: 17 additions & 1 deletion tools/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created: Wed Aug 8 09:44:45 2012
# Created: Mon Aug 13 18:16:52 2012
# by: PyQt4 UI code generator 4.9.1
#
# WARNING! All changes made in this file will be lost!
Expand All @@ -28,6 +28,7 @@ def setupUi(self, MainWindow):
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.label_2 = QtGui.QLabel(self.centralwidget)
self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.horizontalLayout.addWidget(self.label_2)
self.bitDepthComboBox = QtGui.QComboBox(self.centralwidget)
Expand All @@ -39,14 +40,26 @@ def setupUi(self, MainWindow):
self.bitDepthComboBox.addItem(_fromUtf8(""))
self.bitDepthComboBox.addItem(_fromUtf8(""))
self.horizontalLayout.addWidget(self.bitDepthComboBox)
self.endianCheckBox = QtGui.QCheckBox(self.centralwidget)
self.endianCheckBox.setObjectName(_fromUtf8("endianCheckBox"))
self.horizontalLayout.addWidget(self.endianCheckBox)
self.wrapCheckBox = QtGui.QCheckBox(self.centralwidget)
self.wrapCheckBox.setChecked(True)
self.wrapCheckBox.setTristate(False)
self.wrapCheckBox.setObjectName(_fromUtf8("wrapCheckBox"))
self.horizontalLayout.addWidget(self.wrapCheckBox)
self.label = QtGui.QLabel(self.centralwidget)
self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label.setObjectName(_fromUtf8("label"))
self.horizontalLayout.addWidget(self.label)
self.rowStrideBox = QtGui.QSpinBox(self.centralwidget)
self.rowStrideBox.setMinimum(1)
self.rowStrideBox.setMaximum(2096)
self.rowStrideBox.setObjectName(_fromUtf8("rowStrideBox"))
self.horizontalLayout.addWidget(self.rowStrideBox)
self.saveButton = QtGui.QPushButton(self.centralwidget)
self.saveButton.setObjectName(_fromUtf8("saveButton"))
self.horizontalLayout.addWidget(self.saveButton)
self.verticalLayout_2.addLayout(self.horizontalLayout)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
Expand All @@ -69,5 +82,8 @@ def retranslateUi(self, MainWindow):
self.bitDepthComboBox.setItemText(3, QtGui.QApplication.translate("MainWindow", "8", None, QtGui.QApplication.UnicodeUTF8))
self.bitDepthComboBox.setItemText(4, QtGui.QApplication.translate("MainWindow", "16", None, QtGui.QApplication.UnicodeUTF8))
self.bitDepthComboBox.setItemText(5, QtGui.QApplication.translate("MainWindow", "24", None, QtGui.QApplication.UnicodeUTF8))
self.endianCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Little-endian", None, QtGui.QApplication.UnicodeUTF8))
self.wrapCheckBox.setText(QtGui.QApplication.translate("MainWindow", "Wrap image", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("MainWindow", "Row Stride (bytes)", None, QtGui.QApplication.UnicodeUTF8))
self.saveButton.setText(QtGui.QApplication.translate("MainWindow", "Save Image...", None, QtGui.QApplication.UnicodeUTF8))

33 changes: 33 additions & 0 deletions tools/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<property name="text">
<string>Bit Depth</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -61,11 +64,34 @@
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="endianCheckBox">
<property name="text">
<string>Little-endian</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="wrapCheckBox">
<property name="text">
<string>Wrap image</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Row Stride (bytes)</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
Expand All @@ -78,6 +104,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveButton">
<property name="text">
<string>Save Image...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
30 changes: 19 additions & 11 deletions tools/rom-explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,39 @@ def __init__(self, path):
self.depth = 1
self.stride = 1
self.bigendian = 1
self.maxDim = 600
self.rebuildImage()

def rebuildImage(self):
width = self.stride * (8 / self.depth)
height = int(math.ceil(self.size / float(self.stride)))
self.img = QtGui.QImage(width,height,QtGui.QImage.Format_Mono)
byteidx = 0
try:
for y in range(height):
line = self.img.scanLine(y)
line.setsize(self.stride)
for y in range(height):
line = self.img.scanLine(y)
line.setsize(self.stride)
try:
for x in range(self.stride):
line[x] = self.data[byteidx]
byteidx = byteidx + 1
except IndexError:
# zero out the rest of the image
pass
except IndexError:
# zero out the rest of the scan line
buf = "\x00"
for x in range(x,self.stride):
line[x] = buf[0]
self.width = width
self.height = height
self.xstrips = 1
if self.height > self.maxDim:
self.xstrips = (self.height + self.maxDim - 1)/self.maxDim

def paint(self, qpainter, qoptions, widget=None):
qpainter.drawImage(0,0,self.img)
vh = min(self.height,self.maxDim)
for strip in range(self.xstrips):
qpainter.drawImage(strip*self.width,0,self.img,0,vh*strip,self.width,vh)

def boundingRect(self):
width = self.stride * (8 / self.depth)
height = int(math.ceil(self.size / float(self.stride)))
return QtCore.QRectF(0,0,width, height)
return QtCore.QRectF(0,0, self.width * self.xstrips, min(self.height,self.maxDim))


class MainWindow(QtGui.QMainWindow):
Expand Down

0 comments on commit 0e3bb4e

Please sign in to comment.